[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELPA] New package: activities
From: |
Drew Adams |
Subject: |
Re: [ELPA] New package: activities |
Date: |
Sat, 27 Jan 2024 19:20:47 +0000 |
Just one comment about desktop.el, FWIW.
I've said this more than once over the
decades, but I'll mention it again since
the question of desktop files being limited
by being directory-based has come up again
in this thread (as only one small part of
this thread).
There's no reason desktop files should be
limited in this way. You should be able to
have multiple desktop files in a directory.
There's no necessary relation between a
desktop file and any particular directory.
It's a design bug, IMO.
I fixed this long ago, in order to let you
bookmark desktops flexibly. A trivial fix
lets you load an arbitrary desktop file.
This 2019 post covers this, but there are
likely older posts by me that do the same:
https://lists.gnu.org/archive/html/emacs-devel/2019-09/msg00571.html
Here again is the code that fixes this
design oversight, FWIW:
(defun bmkp-desktop-save (desktop-file)
"Save current desktop in DESKTOP-FILE."
(let ((desktop-base-file-name
(file-name-nondirectory desktop-file))
(desk-dir
(file-name-directory desktop-file))
(desktop-restore-eager t)) ; Don't bother w/ lazy.
(desktop-save desk-dir 'RELEASE 'AUTOSAVE)))
;; Derived from code in `desktop-read'.
;;
(defun bmkp-desktop-read (file)
"Load desktop-file FILE, then run `desktop-after-read-hook'.
Return t if FILE was loaded, nil otherwise."
(interactive)
(when (file-directory-p file)
(error "`%s' is a directory, not a file" file))
(setq desktop-dirname (file-name-directory file))
(if (not (file-readable-p file))
nil ; Return nil: not loaded.
(let ((desktop-restore-eager t) ; Don't bother w/ lazy.
(desktop-first-buffer nil)
(desktop-buffer-ok-count 0)
(desktop-buffer-fail-count 0)
;; Prevent desktop-saving for eval of desktop buffer.
(desktop-save nil))
(desktop-lazy-abort)
(load file t t t)
(setq desktop-file-modtime (nth 5 (file-attributes file)))
(mapc 'bury-buffer
(nreverse (cdr (memq desktop-first-buffer
(nreverse (buffer-list))))))
(switch-to-buffer (car (buffer-list)))
(run-hooks 'desktop-delay-hook)
(setq desktop-delay-hook ())
(run-hooks 'desktop-after-read-hook)
(message "Desktop: %d buffer%s restored%s%s."
desktop-buffer-ok-count
(if (= 1 desktop-buffer-ok-count) "" "s")
(if (< 0 desktop-buffer-fail-count)
(format ", %d failed to restore"
desktop-buffer-fail-count)
"")
(if desktop-buffer-args-list
(format ", %d to be restored lazily"
(length desktop-buffer-args-list))
""))
t))) ; Return t: successfully loaded.
Re: [ELPA] New package: activities, Eshel Yaron, 2024/01/26
Re: [ELPA] New package: activities, JD Smith, 2024/01/29
Re: [ELPA] New package: activities,
Drew Adams <=