Commit 1f7efe1b authored by Juanma Barranquero's avatar Juanma Barranquero

(desktop-load-locked-desktop): New option.

(desktop-read): Use it.
(desktop-truncate, desktop-outvar, desktop-restore-file-buffer): Use `when'.
parent e88110db
2007-06-12 Juanma Barranquero <lekktu@gmail.com>
* desktop.el (desktop-load-locked-desktop): New option.
(desktop-read): Use it.
(desktop-truncate, desktop-outvar, desktop-restore-file-buffer):
Use `when'.
2007-06-12 Davis Herring <herring@lanl.gov>
* desktop.el (desktop-save-mode-off): New function.
......
......@@ -190,6 +190,22 @@ determine where the desktop is saved."
:group 'desktop
:version "22.1")
(defcustom desktop-load-locked-desktop 'ask
"Specifies whether the desktop should be loaded if locked.
Possible values are:
t -- load anyway.
nil -- don't load.
ask -- ask the user.
If the value is nil, or `ask' and the user chooses not to load the desktop,
the normal hook `desktop-not-loaded-hook' is run."
:type
'(choice
(const :tag "Load anyway" t)
(const :tag "Don't load" nil)
(const :tag "Ask the user" ask))
:group 'desktop
:version "23.1")
(defcustom desktop-base-file-name
(convert-standard-filename ".emacs.desktop")
"Name of file for Emacs desktop, excluding the directory part."
......@@ -557,7 +573,7 @@ DIRNAME omitted or nil means use `desktop-dirname'."
(defun desktop-truncate (list n)
"Truncate LIST to at most N elements destructively."
(let ((here (nthcdr (1- n) list)))
(if (consp here)
(when (consp here)
(setcdr here nil))))
;; ----------------------------------------------------------------------------
......@@ -776,9 +792,8 @@ which means to truncate VAR's value to at most MAX-SIZE elements
(if (consp varspec)
(setq var (car varspec) size (cdr varspec))
(setq var varspec))
(if (boundp var)
(progn
(if (and (integerp size)
(when (boundp var)
(when (and (integerp size)
(> size 0)
(listp (eval var)))
(desktop-truncate (eval var) size))
......@@ -786,7 +801,7 @@ which means to truncate VAR's value to at most MAX-SIZE elements
(symbol-name var)
" "
(desktop-value-to-string (symbol-value var))
")\n")))))
")\n"))))
;; ----------------------------------------------------------------------------
(defun desktop-save-buffer-p (filename bufname mode &rest dummy)
......@@ -944,9 +959,12 @@ It returns t if a desktop file was loaded, nil otherwise."
;; Avoid desktop saving during evaluation of desktop buffer.
(desktop-save nil))
(if (and owner
(memq desktop-load-locked-desktop '(nil ask))
(or (null desktop-load-locked-desktop)
(not (y-or-n-p (format "Warning: desktop file appears to be in use by PID %s.\n\
Using it may cause conflicts. Use it anyway? " owner))))
(progn (setq desktop-dirname nil)
Using it may cause conflicts. Use it anyway? " owner)))))
(progn
(setq desktop-dirname nil)
(let ((default-directory desktop-dirname))
(run-hooks 'desktop-not-loaded-hook))
(message "Desktop file in use; not loaded."))
......@@ -1044,7 +1062,7 @@ directory DIRNAME."
desktop-buffer-name
desktop-buffer-misc)
"Restore a file buffer."
(if desktop-buffer-file-name
(when desktop-buffer-file-name
(if (or (file-exists-p desktop-buffer-file-name)
(let ((msg (format "Desktop: File \"%s\" no longer exists."
desktop-buffer-file-name)))
......@@ -1165,7 +1183,7 @@ directory DIRNAME."
(setq mark-active (car (cdr desktop-buffer-mark))))
(set-mark desktop-buffer-mark)))
;; Never override file system if the file really is read-only marked.
(if desktop-buffer-read-only (setq buffer-read-only desktop-buffer-read-only))
(when desktop-buffer-read-only (setq buffer-read-only desktop-buffer-read-only))
(while desktop-buffer-locals
(let ((this (car desktop-buffer-locals)))
(if (consp this)
......
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