Commit 5414a283 authored by Juanma Barranquero's avatar Juanma Barranquero
Browse files

lisp/desktop.el (desktop-clear): Be more careful about deleting frames.

Do it only when called interactively and desktop-restore-frames is non-nil.
Doc fix.
(desktop-read): Set desktop-saved-frameset to nil.
parent 98f638d6
2013-08-04 Juanma Barranquero <lekktu@gmail.com>
* desktop.el (desktop-clear): Only delete frames when called
interactively and desktop-restore-frames is non-nil. Doc fix.
(desktop-read): Set desktop-saved-frameset to nil.
2013-08-03 Juanma Barranquero <lekktu@gmail.com> 2013-08-03 Juanma Barranquero <lekktu@gmail.com>
* frameset.el (frameset-prop): New function and setter. * frameset.el (frameset-prop): New function and setter.
......
...@@ -643,7 +643,10 @@ DIRNAME omitted or nil means use `desktop-dirname'." ...@@ -643,7 +643,10 @@ DIRNAME omitted or nil means use `desktop-dirname'."
"Empty the Desktop. "Empty the Desktop.
This kills all buffers except for internal ones and those with names matched by This kills all buffers except for internal ones and those with names matched by
a regular expression in the list `desktop-clear-preserve-buffers'. a regular expression in the list `desktop-clear-preserve-buffers'.
Furthermore, it clears the variables listed in `desktop-globals-to-clear'." Furthermore, it clears the variables listed in `desktop-globals-to-clear'.
When called interactively and `desktop-restore-frames' is non-nil, it also
deletes all frames except the selected one (and its minibuffer frame,
if different)."
(interactive) (interactive)
(desktop-lazy-abort) (desktop-lazy-abort)
(dolist (var desktop-globals-to-clear) (dolist (var desktop-globals-to-clear)
...@@ -662,16 +665,20 @@ Furthermore, it clears the variables listed in `desktop-globals-to-clear'." ...@@ -662,16 +665,20 @@ Furthermore, it clears the variables listed in `desktop-globals-to-clear'."
(string-match-p preserve-regexp bufname)) (string-match-p preserve-regexp bufname))
(kill-buffer buffer))))) (kill-buffer buffer)))))
(delete-other-windows) (delete-other-windows)
(let* ((this (selected-frame)) (when (and desktop-restore-frames
(mini (window-frame (minibuffer-window this)))) ; in case they difer ;; Non-interactive calls to desktop-clear happen before desktop-read
(dolist (frame (sort (frame-list) #'frameset-sort-frames-for-deletion)) ;; which already takes care of frame restoration and deletion.
(condition-case err (called-interactively-p 'any))
(unless (or (eq frame this) (let* ((this (selected-frame))
(eq frame mini) (mini (window-frame (minibuffer-window this)))) ; in case they difer
(frame-parameter frame 'desktop-dont-clear)) (dolist (frame (sort (frame-list) #'frameset-sort-frames-for-deletion))
(delete-frame frame)) (condition-case err
(error (unless (or (eq frame this)
(delay-warning 'desktop (error-message-string err))))))) (eq frame mini)
(frame-parameter frame 'desktop-dont-clear))
(delete-frame frame))
(error
(delay-warning 'desktop (error-message-string err))))))))
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
(unless noninteractive (unless noninteractive
...@@ -1152,6 +1159,7 @@ Using it may cause conflicts. Use it anyway? " owner))))) ...@@ -1152,6 +1159,7 @@ Using it may cause conflicts. Use it anyway? " owner)))))
(walk-window-tree (lambda (window) (walk-window-tree (lambda (window)
(set-window-prev-buffers window nil) (set-window-prev-buffers window nil)
(set-window-next-buffers window nil)))) (set-window-next-buffers window nil))))
(setq desktop-saved-frameset nil)
t)) t))
;; No desktop file found. ;; No desktop file found.
(desktop-clear) (desktop-clear)
......
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