diff options
| author | Michael Albinus | 2026-01-07 10:08:45 +0100 |
|---|---|---|
| committer | Michael Albinus | 2026-01-07 10:08:45 +0100 |
| commit | d7fd87b403d5b9ae0e2c2937ddd23e855f3263a2 (patch) | |
| tree | bb31a6ba4f5a9cff358dbff34c744f280f1b01b8 | |
| parent | 073455ccb8024d1ce1a46305913390a193136429 (diff) | |
| download | emacs-d7fd87b403d5b9ae0e2c2937ddd23e855f3263a2.tar.gz emacs-d7fd87b403d5b9ae0e2c2937ddd23e855f3263a2.zip | |
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.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/shadowfile.el | 16 |
2 files changed, 17 insertions, 4 deletions
| @@ -3339,6 +3339,11 @@ If an active region exists, the commands 'hi-lock-line-face-buffer' and | |||
| 3339 | 'hi-lock-face-phrase-buffer' now use its contents as their default | 3339 | 'hi-lock-face-phrase-buffer' now use its contents as their default |
| 3340 | value. Previously, only 'hi-lock-face-buffer' supported this. | 3340 | value. Previously, only 'hi-lock-face-buffer' supported this. |
| 3341 | 3341 | ||
| 3342 | ** Shadowfile | ||
| 3343 | |||
| 3344 | *** 'shadow-info-buffer' and 'shadow-todo-buffer' use eqhemeral buffer names now. | ||
| 3345 | This excludes the buffers from save buffer predicates. | ||
| 3346 | |||
| 3342 | 3347 | ||
| 3343 | * New Modes and Packages in Emacs 31.1 | 3348 | * New Modes and Packages in Emacs 31.1 |
| 3344 | 3349 | ||
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." | |||
| 667 | (setq shadow-files-to-copy | 667 | (setq shadow-files-to-copy |
| 668 | (cl-remove-if (lambda (s) (eq s pair)) shadow-files-to-copy))) | 668 | (cl-remove-if (lambda (s) (eq s pair)) shadow-files-to-copy))) |
| 669 | 669 | ||
| 670 | (defun shadow-find-file-noselect (filename &optional nowarn) | ||
| 671 | "Like `find-file-noselect', but make buffer name ephemeral." | ||
| 672 | (with-current-buffer (find-file-noselect filename nowarn) | ||
| 673 | (rename-buffer (format " *%s*" (buffer-name))) | ||
| 674 | (current-buffer))) | ||
| 675 | |||
| 670 | (defun shadow-read-files () | 676 | (defun shadow-read-files () |
| 671 | "Visit and load `shadow-info-file' and `shadow-todo-file'. | 677 | "Visit and load `shadow-info-file' and `shadow-todo-file'. |
| 672 | Thus restores shadowfile's state from your last Emacs session. | 678 | Thus restores shadowfile's state from your last Emacs session. |
| @@ -682,7 +688,7 @@ Return t unless files were locked; then return nil." | |||
| 682 | (save-current-buffer | 688 | (save-current-buffer |
| 683 | (when shadow-info-file | 689 | (when shadow-info-file |
| 684 | (set-buffer (setq shadow-info-buffer | 690 | (set-buffer (setq shadow-info-buffer |
| 685 | (find-file-noselect shadow-info-file 'nowarn))) | 691 | (shadow-find-file-noselect shadow-info-file 'nowarn))) |
| 686 | (lisp-data-mode) | 692 | (lisp-data-mode) |
| 687 | (setq-local lexical-binding t) | 693 | (setq-local lexical-binding t) |
| 688 | (when (and (not (buffer-modified-p)) | 694 | (when (and (not (buffer-modified-p)) |
| @@ -695,7 +701,7 @@ Return t unless files were locked; then return nil." | |||
| 695 | (eval-buffer)) | 701 | (eval-buffer)) |
| 696 | (when shadow-todo-file | 702 | (when shadow-todo-file |
| 697 | (set-buffer (setq shadow-todo-buffer | 703 | (set-buffer (setq shadow-todo-buffer |
| 698 | (find-file-noselect shadow-todo-file 'nowarn))) | 704 | (shadow-find-file-noselect shadow-todo-file 'nowarn))) |
| 699 | (lisp-data-mode) | 705 | (lisp-data-mode) |
| 700 | (setq-local lexical-binding t) | 706 | (setq-local lexical-binding t) |
| 701 | (when (and (not (buffer-modified-p)) | 707 | (when (and (not (buffer-modified-p)) |
| @@ -717,7 +723,8 @@ defined, the old hashtable info is invalid." | |||
| 717 | (if shadow-info-file | 723 | (if shadow-info-file |
| 718 | (save-current-buffer | 724 | (save-current-buffer |
| 719 | (if (not shadow-info-buffer) | 725 | (if (not shadow-info-buffer) |
| 720 | (setq shadow-info-buffer (find-file-noselect shadow-info-file))) | 726 | (setq shadow-info-buffer |
| 727 | (shadow-find-file-noselect shadow-info-file))) | ||
| 721 | (set-buffer shadow-info-buffer) | 728 | (set-buffer shadow-info-buffer) |
| 722 | (setq buffer-read-only nil) | 729 | (setq buffer-read-only nil) |
| 723 | (delete-region (point-min) (point-max)) | 730 | (delete-region (point-min) (point-max)) |
| @@ -730,7 +737,8 @@ defined, the old hashtable info is invalid." | |||
| 730 | With non-nil argument also saves the buffer." | 737 | With non-nil argument also saves the buffer." |
| 731 | (save-excursion | 738 | (save-excursion |
| 732 | (if (not shadow-todo-buffer) | 739 | (if (not shadow-todo-buffer) |
| 733 | (setq shadow-todo-buffer (find-file-noselect shadow-todo-file))) | 740 | (setq shadow-todo-buffer |
| 741 | (shadow-find-file-noselect shadow-todo-file))) | ||
| 734 | (set-buffer shadow-todo-buffer) | 742 | (set-buffer shadow-todo-buffer) |
| 735 | (setq buffer-read-only nil) | 743 | (setq buffer-read-only nil) |
| 736 | (delete-region (point-min) (point-max)) | 744 | (delete-region (point-min) (point-max)) |