1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-15 07:41:09 -08:00

shadowfile.el uses eqhemeral buffer names now

* etc/NEWS: shadowfile.el uses eqhemeral buffer names now.

* lisp/shadowfile.el (shadow-find-file-noselect): New function.
(shadow-read-files, shadow-write-info-file)
(shadow-write-todo-file): Use it.
This commit is contained in:
Michael Albinus 2026-01-07 10:08:45 +01:00
parent 073455ccb8
commit d7fd87b403
2 changed files with 17 additions and 4 deletions

View file

@ -3339,6 +3339,11 @@ If an active region exists, the commands 'hi-lock-line-face-buffer' and
'hi-lock-face-phrase-buffer' now use its contents as their default
value. Previously, only 'hi-lock-face-buffer' supported this.
** Shadowfile
*** 'shadow-info-buffer' and 'shadow-todo-buffer' use eqhemeral buffer names now.
This excludes the buffers from save buffer predicates.
* New Modes and Packages in Emacs 31.1

View file

@ -667,6 +667,12 @@ PAIR must be `eq' to one of the elements of that list."
(setq shadow-files-to-copy
(cl-remove-if (lambda (s) (eq s pair)) shadow-files-to-copy)))
(defun shadow-find-file-noselect (filename &optional nowarn)
"Like `find-file-noselect', but make buffer name ephemeral."
(with-current-buffer (find-file-noselect filename nowarn)
(rename-buffer (format " *%s*" (buffer-name)))
(current-buffer)))
(defun shadow-read-files ()
"Visit and load `shadow-info-file' and `shadow-todo-file'.
Thus restores shadowfile's state from your last Emacs session.
@ -682,7 +688,7 @@ Return t unless files were locked; then return nil."
(save-current-buffer
(when shadow-info-file
(set-buffer (setq shadow-info-buffer
(find-file-noselect shadow-info-file 'nowarn)))
(shadow-find-file-noselect shadow-info-file 'nowarn)))
(lisp-data-mode)
(setq-local lexical-binding t)
(when (and (not (buffer-modified-p))
@ -695,7 +701,7 @@ Return t unless files were locked; then return nil."
(eval-buffer))
(when shadow-todo-file
(set-buffer (setq shadow-todo-buffer
(find-file-noselect shadow-todo-file 'nowarn)))
(shadow-find-file-noselect shadow-todo-file 'nowarn)))
(lisp-data-mode)
(setq-local lexical-binding t)
(when (and (not (buffer-modified-p))
@ -717,7 +723,8 @@ defined, the old hashtable info is invalid."
(if shadow-info-file
(save-current-buffer
(if (not shadow-info-buffer)
(setq shadow-info-buffer (find-file-noselect shadow-info-file)))
(setq shadow-info-buffer
(shadow-find-file-noselect shadow-info-file)))
(set-buffer shadow-info-buffer)
(setq buffer-read-only nil)
(delete-region (point-min) (point-max))
@ -730,7 +737,8 @@ defined, the old hashtable info is invalid."
With non-nil argument also saves the buffer."
(save-excursion
(if (not shadow-todo-buffer)
(setq shadow-todo-buffer (find-file-noselect shadow-todo-file)))
(setq shadow-todo-buffer
(shadow-find-file-noselect shadow-todo-file)))
(set-buffer shadow-todo-buffer)
(setq buffer-read-only nil)
(delete-region (point-min) (point-max))