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

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

[nongnu] elpa/with-editor ecff6bb 019/140: with-editor-file-name-history


From: Jonas Bernoulli
Subject: [nongnu] elpa/with-editor ecff6bb 019/140: with-editor-file-name-history-exclude: new variable
Date: Fri, 6 Aug 2021 12:51:11 -0400 (EDT)

branch: elpa/with-editor
commit ecff6bb717c7a775228c7171c2b2fe67868b849f
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    with-editor-file-name-history-exclude: new variable
---
 with-editor.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/with-editor.el b/with-editor.el
index babbd81..fa01a9d 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -252,6 +252,12 @@ Note that when a package adds an entry here then it 
probably
 has a reason to disrespect `server-window' and it likely is
 not a good idea to change such entries.")
 
+(defvar with-editor-file-name-history-exclude nil
+  "List of regexps for filenames `server-visit' should no remember.
+When a filename matches any of the regexps, then `server-visit'
+does not add it to the variable `file-name-history', which is
+used when reading a filename in the minibuffer.")
+
 ;;; Mode Commands
 
 (defvar with-editor-pre-finish-hook nil)
@@ -530,6 +536,16 @@ which may or may not insert the text into the PROCESS' 
buffer."
   (unless no-default-filter
     (internal-default-process-filter process string)))
 
+(advice-add 'server-visit-files :after
+            'server-visit-files--with-editor-file-name-history-exclude)
+
+(defun server-visit-files--with-editor-file-name-history-exclude
+    (files _proc &optional _nowait)
+  (pcase-dolist (`(,file _) files)
+    (when (--any (string-match-p it file)
+                 with-editor-file-name-history-exclude)
+      (setq file-name-history (delete file file-name-history)))))
+
 ;;; Augmentations
 
 (cl-defun with-editor-export-editor (&optional (envvar "EDITOR"))



reply via email to

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