branch: elpa/with-editor
commit ecff6bb717c7a775228c7171c2b2fe67868b849f
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
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"))