From d7fd87b403d5b9ae0e2c2937ddd23e855f3263a2 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 7 Jan 2026 10:08:45 +0100 Subject: [PATCH] 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. --- etc/NEWS | 5 +++++ lisp/shadowfile.el | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7cc2cca65f8..a9d5329bce8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el index 7fd7dc94ad0..7f4f5b56a1f 100644 --- a/lisp/shadowfile.el +++ b/lisp/shadowfile.el @@ -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))