summaryrefslogtreecommitdiff
path: root/lisp/desktop.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/desktop.el')
-rw-r--r--lisp/desktop.el110
1 files changed, 52 insertions, 58 deletions
diff --git a/lisp/desktop.el b/lisp/desktop.el
index a14abdd8fc1..97c057e2013 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -158,14 +158,9 @@ Used at desktop read to provide backward compatibility.")
"Save status of Emacs when you exit."
:group 'frames)
-;; Maintained for backward compatibility
-(define-obsolete-variable-alias 'desktop-enable 'desktop-save-mode "22.1")
;;;###autoload
(define-minor-mode desktop-save-mode
"Toggle desktop saving (Desktop Save mode).
-With a prefix argument ARG, enable Desktop Save mode if ARG is positive,
-and disable it otherwise. If called from Lisp, enable the mode if ARG
-is omitted or nil.
When Desktop Save mode is enabled, the state of Emacs is saved from
one session to another. In particular, Emacs will save the desktop when
@@ -248,9 +243,6 @@ the normal hook `desktop-not-loaded-hook' is run."
:group 'desktop
:version "22.2")
-(define-obsolete-variable-alias 'desktop-basefilename
- 'desktop-base-file-name "22.1")
-
(defcustom desktop-base-file-name
(convert-standard-filename ".emacs.desktop")
"Name of file for Emacs desktop, excluding the directory part."
@@ -392,7 +384,7 @@ or `desktop-modes-not-to-save'."
;; Skip tramp and ange-ftp files
(defcustom desktop-files-not-to-save
- "\\(^/[^/:]*:\\|(ftp)$\\)"
+ "\\(\\`/[^/:]*:\\|(ftp)\\'\\)"
"Regexp identifying files whose buffers are to be excluded from saving.
The default value excludes buffers visiting remote files."
:type '(choice (const :tag "None" nil)
@@ -494,10 +486,6 @@ When file names are returned, they should be formatted using the call
Later, when `desktop-read' evaluates the desktop file, auxiliary information
is passed as the argument DESKTOP-BUFFER-MISC to functions in
`desktop-buffer-mode-handlers'.")
-(make-obsolete-variable 'desktop-buffer-modes-to-save
- 'desktop-save-buffer "22.1")
-(make-obsolete-variable 'desktop-buffer-misc-functions
- 'desktop-save-buffer "22.1")
;;;###autoload
(defvar desktop-buffer-mode-handlers nil
@@ -541,12 +529,9 @@ can guess how to load the mode's definition.")
;;;###autoload
(put 'desktop-buffer-mode-handlers 'risky-local-variable t)
-(make-obsolete-variable 'desktop-buffer-handlers
- 'desktop-buffer-mode-handlers "22.1")
(defcustom desktop-minor-mode-table
- '((auto-fill-function auto-fill-mode)
- (defining-kbd-macro nil)
+ '((defining-kbd-macro nil)
(isearch-mode nil)
(vc-mode nil)
(vc-dired-mode nil)
@@ -713,12 +698,12 @@ if different)."
(if (symbolp var)
(set-default var nil)
(set-default var (eval (cdr var)))))
- (let ((preserve-regexp (concat "^\\("
+ (let ((preserve-regexp (concat "\\`\\("
(mapconcat (lambda (regexp)
(concat "\\(" regexp "\\)"))
desktop-clear-preserve-buffers
"\\|")
- "\\)$")))
+ "\\)\\'")))
(dolist (buffer (buffer-list))
(let ((bufname (buffer-name buffer)))
(unless (or (eq (aref bufname 0) ?\s) ;; Don't kill internal buffers
@@ -746,7 +731,7 @@ if different)."
;; ----------------------------------------------------------------------------
(unless noninteractive
- (add-hook 'kill-emacs-hook 'desktop-kill))
+ (add-hook 'kill-emacs-hook #'desktop-kill))
(defun desktop-kill ()
"If `desktop-save-mode' is non-nil, do what `desktop-save' says to do.
@@ -815,6 +800,7 @@ buffer, which is (in order):
(symbol-value minor-mode)
(let* ((special (assq minor-mode desktop-minor-mode-table))
(value (cond (special (cadr special))
+ ((get minor-mode :minor-mode-function))
((functionp minor-mode) minor-mode))))
(when value (cl-pushnew value ret))))))
;; point and mark, and read-only status
@@ -852,10 +838,12 @@ QUOTE may be `may' (value may be quoted),
((or (numberp value) (null value) (eq t value) (keywordp value))
(cons 'may value))
((stringp value)
- (let ((copy (copy-sequence value)))
- (set-text-properties 0 (length copy) nil copy)
- ;; Get rid of text properties because we cannot read them.
- (cons 'may copy)))
+ ;; Get rid of unreadable text properties.
+ (if (condition-case nil (read (format "%S" value)) (error nil))
+ (cons 'may value)
+ (let ((copy (copy-sequence value)))
+ (set-text-properties 0 (length copy) nil copy)
+ (cons 'may copy))))
((symbolp value)
(cons 'must value))
((vectorp value)
@@ -868,6 +856,19 @@ QUOTE may be `may' (value may be quoted),
`',(cdr el) (cdr el)))
pass1)))
(cons 'may `[,@(mapcar #'cdr pass1)]))))
+ ((and (recordp value) (symbolp (aref value 0)))
+ (let* ((pass1 (let ((res ()))
+ (dotimes (i (length value))
+ (push (desktop--v2s (aref value i)) res))
+ (nreverse res)))
+ (special (assq nil pass1)))
+ (if special
+ (cons nil `(record
+ ,@(mapcar (lambda (el)
+ (if (eq (car el) 'must)
+ `',(cdr el) (cdr el)))
+ pass1)))
+ (cons 'may (apply #'record (mapcar #'cdr pass1))))))
((consp value)
(let ((p value)
newlist
@@ -900,8 +901,8 @@ QUOTE may be `may' (value may be quoted),
(cons nil
`(let ((mk (make-marker)))
(add-hook 'desktop-delay-hook
- `(lambda ()
- (set-marker ,mk ,,pos (get-buffer ,,buf))))
+ (lambda ()
+ (set-marker mk ,pos (get-buffer ,buf))))
mk))))
(t ; Save as text.
(cons 'may "Unprintable entity"))))
@@ -1043,7 +1044,8 @@ without further confirmation."
(setq desktop-dirname (file-name-as-directory (expand-file-name dirname)))
(save-excursion
(let ((eager desktop-restore-eager)
- (new-modtime (nth 5 (file-attributes (desktop-full-file-name)))))
+ (new-modtime (file-attribute-modification-time
+ (file-attributes (desktop-full-file-name)))))
(when
(or (not new-modtime) ; nothing to overwrite
(equal desktop-file-modtime new-modtime)
@@ -1085,7 +1087,7 @@ without further confirmation."
(with-temp-buffer
(insert
- ";; -*- mode: emacs-lisp; coding: emacs-mule; -*-\n"
+ ";; -*- mode: emacs-lisp; lexical-binding:t; coding: utf-8-emacs; -*-\n"
desktop-header
";; Created " (current-time-string) "\n"
";; Desktop file format version " (format "%d" desktop-io-file-version) "\n"
@@ -1098,7 +1100,7 @@ without further confirmation."
(desktop-save-frameset)
(unless (memq 'desktop-saved-frameset desktop-globals-to-save)
(desktop-outvar 'desktop-saved-frameset))
- (mapc (function desktop-outvar) desktop-globals-to-save)
+ (mapc #'desktop-outvar desktop-globals-to-save)
(setq desktop-saved-frameset nil) ; after saving desktop-globals-to-save
(when (memq 'kill-ring desktop-globals-to-save)
(insert
@@ -1107,9 +1109,9 @@ without further confirmation."
" kill-ring))\n"))
(insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n")
- (dolist (l (mapcar 'desktop-buffer-info (buffer-list)))
+ (dolist (l (mapcar #'desktop-buffer-info (buffer-list)))
(let ((base (pop l)))
- (when (apply 'desktop-save-buffer-p l)
+ (when (apply #'desktop-save-buffer-p l)
(insert "("
(if (or (not (integerp eager))
(if (zerop eager)
@@ -1140,13 +1142,15 @@ without further confirmation."
;; This is saved after the timestamp
(search-forward (format "%S" desktop--app-id) nil t))
(point))))
- (checksum (and beg (md5 (current-buffer) beg (point-max) 'emacs-mule))))
+ (checksum (and beg (md5 (current-buffer) beg (point-max) 'utf-8-emacs))))
(unless (and checksum (equal checksum desktop-file-checksum))
- (let ((coding-system-for-write 'emacs-mule))
+ (let ((coding-system-for-write 'utf-8-emacs))
(write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage))
(setq desktop-file-checksum checksum)
;; We remember when it was modified (which is presumably just now).
- (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name)))))))))))
+ (setq desktop-file-modtime (file-attribute-modification-time
+ (file-attributes
+ (desktop-full-file-name)))))))))))
;; ----------------------------------------------------------------------------
;;;###autoload
@@ -1241,16 +1245,18 @@ Using it may cause conflicts. Use it anyway? " owner)))))
;; disabled when loading the desktop fails with errors,
;; thus not overwriting the desktop with broken contents.
(setq desktop-autosave-was-enabled
- (memq 'desktop-auto-save-set-timer
- ;; Use the toplevel value of the hook, in case some
+ (memq #'desktop-auto-save-set-timer
+ ;; Use the global value of the hook, in case some
;; feature makes window-configuration-change-hook
;; buffer-local, and puts there stuff which
;; doesn't include our timer.
- (default-toplevel-value
+ (default-value
'window-configuration-change-hook)))
(desktop-auto-save-disable)
;; Evaluate desktop buffer and remember when it was modified.
- (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))
+ (setq desktop-file-modtime (file-attribute-modification-time
+ (file-attributes
+ (desktop-full-file-name))))
(load (desktop-full-file-name) t t t)
;; If it wasn't already, mark it as in-use, to bother other
;; desktop instances.
@@ -1265,7 +1271,7 @@ Using it may cause conflicts. Use it anyway? " owner)))))
;; We want buffers existing prior to evaluating the desktop (and
;; not reused) to be placed at the end of the buffer list, so we
;; move them here.
- (mapc 'bury-buffer
+ (mapc #'bury-buffer
(nreverse (cdr (memq desktop-first-buffer (nreverse (buffer-list))))))
(switch-to-buffer (car (buffer-list))))
(run-hooks 'desktop-delay-hook)
@@ -1310,17 +1316,6 @@ Using it may cause conflicts. Use it anyway? " owner)))))
nil)))
;; ----------------------------------------------------------------------------
-;; Maintained for backward compatibility
-;;;###autoload
-(defun desktop-load-default ()
- "Load the `default' start-up library manually.
-Also inhibit further loading of it."
- (declare (obsolete desktop-save-mode "22.1"))
- (unless inhibit-default-init ; safety check
- (load "default" t t)
- (setq inhibit-default-init t)))
-
-;; ----------------------------------------------------------------------------
;;;###autoload
(defun desktop-change-dir (dirname)
"Change to desktop saved in DIRNAME.
@@ -1350,10 +1345,10 @@ directory DIRNAME."
(defun desktop-auto-save-enable (&optional timeout)
(when (and (integerp (or timeout desktop-auto-save-timeout))
(> (or timeout desktop-auto-save-timeout) 0))
- (add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)))
+ (add-hook 'window-configuration-change-hook #'desktop-auto-save-set-timer)))
(defun desktop-auto-save-disable ()
- (remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
+ (remove-hook 'window-configuration-change-hook #'desktop-auto-save-set-timer)
(desktop-auto-save-cancel-timer))
(defun desktop-auto-save ()
@@ -1562,11 +1557,10 @@ and try to load that."
;; for the sake of `clean-buffer-list': preserving the invariant
;; "how much time the user spent in Emacs without looking at this buffer".
(setq buffer-display-time
- (if buffer-display-time
- (time-add buffer-display-time
- (time-subtract (current-time)
- desktop-file-modtime))
- (current-time)))
+ (time-since (if buffer-display-time
+ (time-subtract desktop-file-modtime
+ buffer-display-time)
+ 0)))
(unless (< desktop-file-version 208) ; Don't misinterpret any old custom args
(dolist (record compacted-vars)
(let*
@@ -1609,7 +1603,7 @@ ARGS must be an argument list for `desktop-create-buffer'."
(let ((desktop-first-buffer nil)
(desktop-buffer-ok-count 0)
(desktop-buffer-fail-count 0))
- (apply 'desktop-create-buffer args)
+ (apply #'desktop-create-buffer args)
(run-hooks 'desktop-delay-hook)
(setq desktop-delay-hook nil)
(bury-buffer (get-buffer buffer-name))