aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2016-10-18 18:05:51 -0400
committerMark Oteiza2016-10-18 18:05:51 -0400
commit224443922ce169ab0e21ad8495d32b269972c028 (patch)
tree4340e51a607b61f66c98f9ad79527138c44989f3
parent2ce01c494dd013a47f3b98860538cba4a1ef6a2c (diff)
downloademacs-224443922ce169ab0e21ad8495d32b269972c028.tar.gz
emacs-224443922ce169ab0e21ad8495d32b269972c028.zip
Add an option for eshell-input-filter
* etc/NEWS: Document changes. * lisp/eshell/em-hist.el (eshell-input-filter): Set value to function symbol. Change type to a radio for choosing functions. Refer to both new functions. (eshell-input-filter-default): New function. Same body as the previous value of eshell-input-filter. (eshell-input-filter-initial-space): New function.
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/eshell/em-hist.el19
2 files changed, 21 insertions, 5 deletions
diff --git a/etc/NEWS b/etc/NEWS
index c5245bcd18b..4f88de9c5b6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -308,6 +308,13 @@ viewing HTML files and the like.
308breakpoint (e.g. with "f" and "o") by customizing the new option 308breakpoint (e.g. with "f" and "o") by customizing the new option
309'edebug-sit-on-break'. 309'edebug-sit-on-break'.
310 310
311** Eshell
312
313*** 'eshell-input-filter's value is now a named function
314'eshell-input-filter-default', and has a new custom option
315'eshell-input-filter-initial-space' to ignore adding commands prefixed
316with blank space to eshell history.
317
311** eww 318** eww
312 319
313+++ 320+++
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 198b1d017c4..067c5ea7ff2 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -119,15 +119,14 @@ If set to t, history will always be saved, silently."
119 (const :tag "Always save" t)) 119 (const :tag "Always save" t))
120 :group 'eshell-hist) 120 :group 'eshell-hist)
121 121
122(defcustom eshell-input-filter 122(defcustom eshell-input-filter 'eshell-input-filter-default
123 (function
124 (lambda (str)
125 (not (string-match "\\`\\s-*\\'" str))))
126 "Predicate for filtering additions to input history. 123 "Predicate for filtering additions to input history.
127Takes one argument, the input. If non-nil, the input may be saved on 124Takes one argument, the input. If non-nil, the input may be saved on
128the input history list. Default is to save anything that isn't all 125the input history list. Default is to save anything that isn't all
129whitespace." 126whitespace."
130 :type 'function 127 :type '(radio (function-item eshell-input-filter-default)
128 (function-item eshell-input-filter-initial-space)
129 (function :tag "Other function"))
131 :group 'eshell-hist) 130 :group 'eshell-hist)
132 131
133(put 'eshell-input-filter 'risky-local-variable t) 132(put 'eshell-input-filter 'risky-local-variable t)
@@ -206,6 +205,16 @@ element, regardless of any text on the command line. In that case,
206 205
207;;; Functions: 206;;; Functions:
208 207
208(defun eshell-input-filter-default (input)
209 "Do not add blank input to input history.
210Returns non-nil if INPUT is blank."
211 (not (string-match "\\`\\s-*\\'" input)))
212
213(defun eshell-input-filter-initial-space (input)
214 "Do not add input beginning with empty space to history.
215Returns nil if INPUT is prepended by blank space, otherwise non-nil."
216 (not (string-match-p "\\`\\s-+" input)))
217
209(defun eshell-hist-initialize () 218(defun eshell-hist-initialize ()
210 "Initialize the history management code for one Eshell buffer." 219 "Initialize the history management code for one Eshell buffer."
211 (add-hook 'eshell-expand-input-functions 220 (add-hook 'eshell-expand-input-functions