desktop: Update patch

master
Pierre Neidhardt 2018-02-18 12:36:56 +01:00
parent cd5be6b932
commit ab43119565
2 changed files with 16 additions and 9 deletions

View File

@ -258,13 +258,14 @@
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28943.
desktop-auto-save-timeout 5
;; desktop-restore-eager 4 ; Can be annoying as you don't have your last-loaded buffers immediately.
desktop-load-locked-desktop 'ask
;; desktop-load-locked-desktop 'ask
desktop-restore-frames nil
desktop-save t)
(defun ambrevar/desktop-init (_frame)
(desktop-save-mode)
(desktop-read)
(remove-hook 'after-make-frame-functions 'ambrevar/desktop-init))
(defun ambrevar/desktop-init (frame)
(when (frame-parameter frame 'client)
(desktop-save-mode)
(desktop-read)
(remove-hook 'after-make-frame-functions 'ambrevar/desktop-init)))
(add-hook 'after-make-frame-functions 'ambrevar/desktop-init) ; This does not fix the window register restoration.
(add-to-list 'desktop-modes-not-to-save 'pdf-view-mode)
(add-to-list 'desktop-modes-not-to-save 'image-mode)

View File

@ -46,7 +46,7 @@ It returns t if a desktop file was loaded, nil otherwise."
(if (and owner
(memq desktop-load-locked-desktop '(nil ask))
(or (null desktop-load-locked-desktop)
(daemonp)
(and (daemonp) (= (length (visible-frame-list)) 1)) ; PATCH
(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)))))
(let ((default-directory desktop-dirname))
@ -59,12 +59,17 @@ 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
;; PATCH
(memq 'desktop-auto-save-set-timer (default-toplevel-value 'window-configuration-change-hook)))
(memq 'desktop-auto-save-set-timer
;; Use the toplevel 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
'window-configuration-change-hook)))
(desktop-auto-save-disable)
;; Evaluate desktop buffer and remember when it was modified.
(load (desktop-full-file-name) t t t)
(setq desktop-file-modtime (nth 5 (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.
(unless (eq (emacs-pid) owner)
@ -128,6 +133,7 @@ Using it may cause conflicts. Use it anyway? " owner)))))
;;; Upstream decided not to do this because of possible clashes when emacs
;;; process is running remotely. Start desktop-mode in
;;; `after-make-frame-functions' instead.
;; TODO: Upstream provision does not seem to work. Test again.
;; (defun desktop-owner (&optional dirname)
;; "Return the PID of the Emacs process that owns the desktop file in DIRNAME.
;; Return nil if no desktop file found or no Emacs process is using it.