Commit 341c2f07 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(desktop-save, desktop-create-buffer): Replace mapcar with dolist.

(after-init-hook): Don't quote lambda.
(desktop-first-buffer): Don't wrap it in eval-when-compile.
(desktop-internal-v2s): Remove unused var `el'.
(desktop-buffer-major-mode, desktop-buffer-locals): Move out of
desktop-restore-file-buffer.
(desktop-buffer-ok-count, desktop-buffer-fail-count): Move out of
desktop-create-buffer.
parent c429815a
2007-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
* desktop.el (desktop-save, desktop-create-buffer): Replace mapcar with
dolist.
(after-init-hook): Don't quote lambda.
(desktop-first-buffer): Don't wrap it in eval-when-compile.
(desktop-internal-v2s): Remove unused var `el'.
(desktop-buffer-major-mode, desktop-buffer-locals): Move out of
desktop-restore-file-buffer.
(desktop-buffer-ok-count, desktop-buffer-fail-count): Move out of
desktop-create-buffer.
2007-04-10 Chong Yidong <cyd@stupidchicken.com> 2007-04-10 Chong Yidong <cyd@stupidchicken.com>
   
* woman.el (woman-decode-buffer): Postphone macro-set check... * woman.el (woman-decode-buffer): Postphone macro-set check...
...@@ -25,8 +37,8 @@ ...@@ -25,8 +37,8 @@
   
* emacs-lisp/byte-opt.el (byte-optimize-char-before): Remove (move * emacs-lisp/byte-opt.el (byte-optimize-char-before): Remove (move
to bytecomp.el as byte-compile-char-before). to bytecomp.el as byte-compile-char-before).
* emacs-lisp/bytecomp.el (byte-compile-char-before): New * emacs-lisp/bytecomp.el (byte-compile-char-before):
function (modified replacement for byte-optimize-char-before in New function (modified replacement for byte-optimize-char-before in
byte-opt.el). byte-opt.el).
   
2007-04-09 Alan Mackenzie <acm@muc.de> 2007-04-09 Alan Mackenzie <acm@muc.de>
...@@ -76,8 +88,8 @@ ...@@ -76,8 +88,8 @@
   
2007-04-08 Johan Bockg,Ae(Brd <bojohan+news@dd.chalmers.se> 2007-04-08 Johan Bockg,Ae(Brd <bojohan+news@dd.chalmers.se>
   
* term/xterm.el (terminal-init-xterm): Fix key definitions. Add * term/xterm.el (terminal-init-xterm): Fix key definitions.
binding for C-M-SPC. Add binding for C-M-SPC.
   
2007-04-08 Richard Stallman <rms@gnu.org> 2007-04-08 Richard Stallman <rms@gnu.org>
   
...@@ -142,8 +154,8 @@ ...@@ -142,8 +154,8 @@
   
* menu-bar.el (menu-bar-tools-menu): Revert 2003-07-25 change. * menu-bar.el (menu-bar-tools-menu): Revert 2003-07-25 change.
   
* desktop.el (desktop-create-buffer, desktop-save): Revert * desktop.el (desktop-create-buffer, desktop-save):
2004-11-12 change. Revert 2004-11-12 change for lack of copyright papers.
   
* dired-x.el (dired-guess-shell-case-fold-search): Delete var. * dired-x.el (dired-guess-shell-case-fold-search): Delete var.
(dired-guess-default): Respect case. (dired-guess-default): Respect case.
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
;; "Saving Emacs Sessions" in the GNU Emacs Manual. ;; "Saving Emacs Sessions" in the GNU Emacs Manual.
;; When the desktop module is loaded, the function `desktop-kill' is ;; When the desktop module is loaded, the function `desktop-kill' is
;; added to the `kill-emacs-hook'. This function is responsible for ;; added to the `kill-emacs-hook'. This function is responsible for
;; saving the desktop when Emacs is killed. Furthermore an anonymous ;; saving the desktop when Emacs is killed. Furthermore an anonymous
;; function is added to the `after-init-hook'. This function is ;; function is added to the `after-init-hook'. This function is
;; responsible for loading the desktop when Emacs is started. ;; responsible for loading the desktop when Emacs is started.
;; Special handling. ;; Special handling.
...@@ -55,12 +55,12 @@ ...@@ -55,12 +55,12 @@
;; Variables `desktop-buffer-mode-handlers' and `desktop-minor-mode-handlers' ;; Variables `desktop-buffer-mode-handlers' and `desktop-minor-mode-handlers'
;; are supplied to handle special major and minor modes respectively. ;; are supplied to handle special major and minor modes respectively.
;; `desktop-buffer-mode-handlers' is an alist of major mode specific functions ;; `desktop-buffer-mode-handlers' is an alist of major mode specific functions
;; to restore a desktop buffer. Elements must have the form ;; to restore a desktop buffer. Elements must have the form
;; ;;
;; (MAJOR-MODE . RESTORE-BUFFER-FUNCTION). ;; (MAJOR-MODE . RESTORE-BUFFER-FUNCTION).
;; ;;
;; Functions listed are called by `desktop-create-buffer' when `desktop-read' ;; Functions listed are called by `desktop-create-buffer' when `desktop-read'
;; evaluates the desktop file. Buffers with a major mode not specified here, ;; evaluates the desktop file. Buffers with a major mode not specified here,
;; are restored by the default handler `desktop-restore-file-buffer'. ;; are restored by the default handler `desktop-restore-file-buffer'.
;; `desktop-minor-mode-handlers' is an alist of functions to restore ;; `desktop-minor-mode-handlers' is an alist of functions to restore
;; non-standard minor modes. Elements must have the form ;; non-standard minor modes. Elements must have the form
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
;; '(bar-mode . bar-desktop-restore)) ;; '(bar-mode . bar-desktop-restore))
;; in the module itself, and make shure that the mode function is ;; in the module itself, and make shure that the mode function is
;; autoloaded. See the docstrings of `desktop-buffer-mode-handlers' and ;; autoloaded. See the docstrings of `desktop-buffer-mode-handlers' and
;; `desktop-minor-mode-handlers' for more info. ;; `desktop-minor-mode-handlers' for more info.
;; Minor modes. ;; Minor modes.
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
;; The variables `desktop-minor-mode-table' and `desktop-minor-mode-handlers' ;; The variables `desktop-minor-mode-table' and `desktop-minor-mode-handlers'
;; are used to handle non-conventional minor modes. `desktop-save' uses ;; are used to handle non-conventional minor modes. `desktop-save' uses
;; `desktop-minor-mode-table' to map minor mode variables to minor mode ;; `desktop-minor-mode-table' to map minor mode variables to minor mode
;; functions before writing `desktop-minor-modes'. If a minor mode has a ;; functions before writing `desktop-minor-modes'. If a minor mode has a
;; variable name that is different form its function name, an entry ;; variable name that is different form its function name, an entry
;; (NAME RESTORE-FUNCTION) ;; (NAME RESTORE-FUNCTION)
...@@ -619,8 +619,7 @@ QUOTE may be `may' (value may be quoted), ...@@ -619,8 +619,7 @@ QUOTE may be `may' (value may be quoted),
(setq newlist (cons q.txt newlist))) (setq newlist (cons q.txt newlist)))
(setq p (cdr p))) (setq p (cdr p)))
(if p (if p
(let ((last (desktop-internal-v2s p)) (let ((last (desktop-internal-v2s p)))
(el (car newlist)))
(or anynil (setq anynil (null (car last)))) (or anynil (setq anynil (null (car last))))
(or anynil (or anynil
(setq newlist (cons '(must . ".") newlist))) (setq newlist (cons '(must . ".") newlist)))
...@@ -782,7 +781,8 @@ See also `desktop-base-file-name'." ...@@ -782,7 +781,8 @@ See also `desktop-base-file-name'."
";; Desktop file format version " desktop-file-version "\n" ";; Desktop file format version " desktop-file-version "\n"
";; Emacs version " emacs-version "\n\n" ";; Emacs version " emacs-version "\n\n"
";; Global section:\n") ";; Global section:\n")
(mapcar (function desktop-outvar) desktop-globals-to-save) (dolist (varspec desktop-globals-to-save)
(desktop-outvar varspec))
(if (memq 'kill-ring desktop-globals-to-save) (if (memq 'kill-ring desktop-globals-to-save)
(insert (insert
"(setq kill-ring-yank-pointer (nthcdr " "(setq kill-ring-yank-pointer (nthcdr "
...@@ -790,22 +790,20 @@ See also `desktop-base-file-name'." ...@@ -790,22 +790,20 @@ See also `desktop-base-file-name'."
" kill-ring))\n")) " kill-ring))\n"))
(insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n")
(mapcar #'(lambda (l) (dolist (l info)
(when (apply 'desktop-save-buffer-p l) (when (apply 'desktop-save-buffer-p l)
(insert "(" (insert "("
(if (or (not (integerp eager)) (if (or (not (integerp eager))
(unless (zerop eager) (unless (zerop eager)
(setq eager (1- eager)) (setq eager (1- eager))
t)) t))
"desktop-create-buffer" "desktop-create-buffer"
"desktop-append-buffer-args") "desktop-append-buffer-args")
" " " "
desktop-file-version) desktop-file-version)
(mapcar #'(lambda (e) (dolist (e l)
(insert "\n " (desktop-value-to-string e))) (insert "\n " (desktop-value-to-string e)))
l) (insert ")\n\n")))
(insert ")\n\n")))
info)
(setq default-directory dirname) (setq default-directory dirname)
(let ((coding-system-for-write 'emacs-mule)) (let ((coding-system-for-write 'emacs-mule))
(write-region (point-min) (point-max) filename nil 'nomessage))))) (write-region (point-min) (point-max) filename nil 'nomessage)))))
...@@ -941,14 +939,13 @@ directory DIRNAME." ...@@ -941,14 +939,13 @@ directory DIRNAME."
(desktop-clear) (desktop-clear)
(desktop-read desktop-dirname)) (desktop-read desktop-dirname))
(defvar desktop-buffer-major-mode)
(defvar desktop-buffer-locals)
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
(defun desktop-restore-file-buffer (desktop-buffer-file-name (defun desktop-restore-file-buffer (desktop-buffer-file-name
desktop-buffer-name desktop-buffer-name
desktop-buffer-misc) desktop-buffer-misc)
"Restore a file buffer." "Restore a file buffer."
(eval-when-compile ; Just to silence the byte compiler
(defvar desktop-buffer-major-mode)
(defvar desktop-buffer-locals))
(if desktop-buffer-file-name (if desktop-buffer-file-name
(if (or (file-exists-p desktop-buffer-file-name) (if (or (file-exists-p desktop-buffer-file-name)
(let ((msg (format "Desktop: File \"%s\" no longer exists." (let ((msg (format "Desktop: File \"%s\" no longer exists."
...@@ -985,8 +982,12 @@ directory DIRNAME." ...@@ -985,8 +982,12 @@ directory DIRNAME."
;; called from Desktop file only. ;; called from Desktop file only.
;; Just to silence the byte compiler. ;; Just to silence the byte compiler.
(eval-when-compile
(defvar desktop-first-buffer)) ; Dynamically bound in `desktop-read' (defvar desktop-first-buffer) ; Dynamically bound in `desktop-read'
;; Bound locally in `desktop-read'.
(defvar desktop-buffer-ok-count)
(defvar desktop-buffer-fail-count)
(defun desktop-create-buffer (defun desktop-create-buffer
(desktop-file-version (desktop-file-version
...@@ -1000,10 +1001,6 @@ directory DIRNAME." ...@@ -1000,10 +1001,6 @@ directory DIRNAME."
desktop-buffer-misc desktop-buffer-misc
&optional &optional
desktop-buffer-locals) desktop-buffer-locals)
;; Just to silence the byte compiler. Bound locally in `desktop-read'.
(eval-when-compile
(defvar desktop-buffer-ok-count)
(defvar desktop-buffer-fail-count))
;; To make desktop files with relative file names possible, we cannot ;; To make desktop files with relative file names possible, we cannot
;; allow `default-directory' to change. Therefore we save current buffer. ;; allow `default-directory' to change. Therefore we save current buffer.
(save-current-buffer (save-current-buffer
...@@ -1045,21 +1042,22 @@ directory DIRNAME." ...@@ -1045,21 +1042,22 @@ directory DIRNAME."
((equal '(nil) desktop-buffer-minor-modes) ; backwards compatible ((equal '(nil) desktop-buffer-minor-modes) ; backwards compatible
(auto-fill-mode 0)) (auto-fill-mode 0))
(t (t
(mapcar #'(lambda (minor-mode) (dolist (minor-mode desktop-buffer-minor-modes)
;; Give minor mode module a chance to add a handler. ;; Give minor mode module a chance to add a handler.
(desktop-load-file minor-mode) (desktop-load-file minor-mode)
(let ((handler (cdr (assq minor-mode desktop-minor-mode-handlers)))) (let ((handler (cdr (assq minor-mode desktop-minor-mode-handlers))))
(if handler (if handler
(funcall handler desktop-buffer-locals) (funcall handler desktop-buffer-locals)
(when (functionp minor-mode) (when (functionp minor-mode)
(funcall minor-mode 1))))) (funcall minor-mode 1)))))))
desktop-buffer-minor-modes))) ;; Even though point and mark are non-nil when written by
;; Even though point and mark are non-nil when written by `desktop-save', ;; `desktop-save', they may be modified by handlers wanting to set
;; they may be modified by handlers wanting to set point or mark themselves. ;; point or mark themselves.
(when desktop-buffer-point (when desktop-buffer-point
(goto-char (goto-char
(condition-case err (condition-case err
;; Evaluate point. Thus point can be something like '(search-forward ... ;; Evaluate point. Thus point can be something like
;; '(search-forward ...
(eval desktop-buffer-point) (eval desktop-buffer-point)
(error (message "%s" (error-message-string err)) 1)))) (error (message "%s" (error-message-string err)) 1))))
(when desktop-buffer-mark (when desktop-buffer-mark
...@@ -1167,7 +1165,7 @@ If there are no buffers left to create, kill the timer." ...@@ -1167,7 +1165,7 @@ If there are no buffers left to create, kill the timer."
;; functions are processed after `after-init-hook'. ;; functions are processed after `after-init-hook'.
(add-hook (add-hook
'after-init-hook 'after-init-hook
'(lambda () (lambda ()
(let ((key "--no-desktop")) (let ((key "--no-desktop"))
(when (member key command-line-args) (when (member key command-line-args)
(setq command-line-args (delete key command-line-args)) (setq command-line-args (delete key command-line-args))
...@@ -1176,5 +1174,5 @@ If there are no buffers left to create, kill the timer." ...@@ -1176,5 +1174,5 @@ If there are no buffers left to create, kill the timer."
(provide 'desktop) (provide 'desktop)
;;; arch-tag: 221907c3-1771-4fd3-9c2e-c6f700c6ede9 ;; arch-tag: 221907c3-1771-4fd3-9c2e-c6f700c6ede9
;;; desktop.el ends here ;;; desktop.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment