emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/wfnames 7202294447 85/98: Allow appending to existing wfna


From: ELPA Syncer
Subject: [nongnu] elpa/wfnames 7202294447 85/98: Allow appending to existing wfnames-buffer
Date: Tue, 8 Aug 2023 04:01:39 -0400 (EDT)

branch: elpa/wfnames
commit 7202294447e3f6e894fe8a1ae88c96ca010ccccd
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Allow appending to existing wfnames-buffer
---
 wfnames.el | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/wfnames.el b/wfnames.el
index 44b2ccbf66..6d013da506 100644
--- a/wfnames.el
+++ b/wfnames.el
@@ -163,11 +163,15 @@ Args BEG and END delimit changes on line."
 
 ;;;###autoload
 (cl-defun wfnames-setup-buffer (files
-                                &optional (display-fn #'switch-to-buffer))
-  "Initialize wfnames buffer with FILES and display it with DISPLAY-FN."
+                                &optional (display-fn #'switch-to-buffer) 
append)
+  "Initialize wfnames buffer with FILES and display it with DISPLAY-FN.
+
+Arg DISPLAY-FN default to `switch-to-buffer' if unspecified.
+When APPEND is specified, append FILES to existing `wfnames-buffer'."
   (with-current-buffer (get-buffer-create wfnames-buffer)
-    (erase-buffer)
+    (unless append (erase-buffer))
     (save-excursion
+      (when append (goto-char (point-max)))
       (cl-loop for file in files
                for face = (cond ((file-directory-p file) 'wfnames-dir)
                                 ((file-symlink-p file) 'wfnames-symlink)
@@ -177,11 +181,13 @@ Args BEG and END delimit changes on line."
                            'line-prefix (propertize
                                          "* "
                                          'face 'wfnames-prefix))
-                          "\n")))
-    ;; Go to beginning of basename on first line.
-    (while (re-search-forward "/" (point-at-eol) t))
-    (wfnames-mode)
-    (funcall display-fn wfnames-buffer)))
+                          "\n"))
+      (when append (delete-duplicate-lines (point-min) (point-max))))
+    (unless append
+      ;; Go to beginning of basename on first line.
+      (while (re-search-forward "/" (point-at-eol) t))
+      (wfnames-mode)
+      (funcall display-fn wfnames-buffer))))
 
 (defun wfnames-ask-for-overwrite (file)
   "Ask before overwriting FILE."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]