desktop: Patch for 26, set up correctly for 27
parent
e7a7e1b19e
commit
697c0dbffe
|
@ -255,7 +255,8 @@
|
|||
;; `server-running-p' is only useful once the daemon is started and cannot be
|
||||
;; used for initialization. Use `daemonp' instead.
|
||||
(require 'desktop)
|
||||
(load "patch-desktop")
|
||||
(when (< emacs-major-version 27)
|
||||
(load "patch-desktop"))
|
||||
(setq history-length 250
|
||||
;; Default timer (30) is way too high: for somebody too frenzy, the timer
|
||||
;; might never be saved. See
|
||||
|
@ -265,12 +266,15 @@
|
|||
;; desktop-load-locked-desktop 'ask
|
||||
desktop-restore-frames nil
|
||||
desktop-save t)
|
||||
(defun ambrevar/desktop-init (frame)
|
||||
(when (frame-parameter frame 'client)
|
||||
;; Before Emacs 27, initialization needs the patch above.
|
||||
(if (< emacs-major-version 27)
|
||||
(desktop-save-mode)
|
||||
(defun ambrevar/desktop-init (_frame)
|
||||
(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.
|
||||
(remove-hook 'server-after-make-frame-hook 'ambrevar/desktop-init))
|
||||
(add-hook 'server-after-make-frame-hook 'ambrevar/desktop-init))
|
||||
;; Discarding PDFs and images makes it lighter.
|
||||
(add-to-list 'desktop-modes-not-to-save 'pdf-view-mode)
|
||||
(add-to-list 'desktop-modes-not-to-save 'image-mode)
|
||||
;; TODO: `compile-history' should be buffer local but that does not work.
|
||||
|
|
|
@ -132,21 +132,20 @@ Using it may cause conflicts. Use it anyway? " owner)))))
|
|||
;;; This assumes that no other name would be using the desktop file.
|
||||
;;; 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.
|
||||
;; DIRNAME omitted or nil means use `desktop-dirname'."
|
||||
;; (let (owner
|
||||
;; (file (desktop-full-lock-name dirname)))
|
||||
;; (and (file-exists-p file)
|
||||
;; (ignore-errors
|
||||
;; (with-temp-buffer
|
||||
;; (insert-file-contents-literally file)
|
||||
;; (goto-char (point-min))
|
||||
;; (setq owner (read (current-buffer)))
|
||||
;; (integerp owner)
|
||||
;; (process-attributes owner)
|
||||
;; (string= "emacs" (alist-get 'comm (process-attributes owner)))))
|
||||
;; owner)))
|
||||
;;; `server-after-make-frame-hook' instead (requires Emacs>=27).
|
||||
(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.
|
||||
DIRNAME omitted or nil means use `desktop-dirname'."
|
||||
(let (owner
|
||||
(file (desktop-full-lock-name dirname)))
|
||||
(and (file-exists-p file)
|
||||
(ignore-errors
|
||||
(with-temp-buffer
|
||||
(insert-file-contents-literally file)
|
||||
(goto-char (point-min))
|
||||
(setq owner (read (current-buffer)))
|
||||
(integerp owner)
|
||||
(process-attributes owner)
|
||||
(string= "emacs" (alist-get 'comm (process-attributes owner)))))
|
||||
owner)))
|
||||
|
|
Loading…
Reference in New Issue