[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Remembering edit files
- To: info-mcl@cambridge.apple.com
- Subject: Remembering edit files
- From: David.Lamkins@p14.f640.n101.z1.fidonet.org (David Lamkins)
- Date: Sat, 09 Nov 91 17:52:21 EST
This is a small enhancement to my MCL environment that I thought others might
like. When I start MCL, I usually want to edit the same files that were open
the last time I quit MCL -- I thought it would be nice to have MCL reopen these
files automatically. The following code, when added to Init.lisp, makes this
happen. Note that this only works for Fred windows that _have_ a file name when
you quit MCL.
--------------
;; Set up a function to remember which files are open when we quit.
(defconstant *window-logfile-name* "CCL;WorkFiles")
(flet ((remember-fred-files ()
(with-open-file (window-log
*window-logfile-name*
:direction :output :if-exists :supersede)
(map-windows
#'(lambda (w)
(let ((fname (window-filename w)))
(when fname (print fname window-log))))
:class 'fred-window))))
;I can't do (advise quit (remember-fred-files)), because quit is already
;bound to the Quit item in the File menu. To make advise work on quit, I'd
;have to bind the advised quit to the menu-item-action-function.
;This is simpler and faster, and who cares about portability?
(pushnew #'remember-fred-files *lisp-cleanup-functions*))
;; Reopen the files that were open last time we quit.
(with-open-file (window-log
*window-logfile-name*
:direction :input :if-does-not-exist nil)
(when window-log (let ((fname))
(loop (setf fname (read window-log nil))
(if fname
(when (probe-file fname)
(ed fname))
(return))))))
--
--- Through FidoNet gateway node 1:16/390
David.Lamkins@p14.f640.n101.z1.fidonet.org