aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Wiegley2002-02-16 07:11:05 +0000
committerJohn Wiegley2002-02-16 07:11:05 +0000
commit7a3bfc32483da1fc0cc68274644a7b2887a35474 (patch)
tree0e32969d1a6016f074dcddb7108f2da6efd9be83
parenteefd92208d757e9a2945e394bd6c729900a11413 (diff)
downloademacs-7a3bfc32483da1fc0cc68274644a7b2887a35474.tar.gz
emacs-7a3bfc32483da1fc0cc68274644a7b2887a35474.zip
(eshell-hist-initialize): When in the minibuffer, use the global value
of `eshell-history-ring', and never save it to disk, or ask to save it to disk. This allows users of session.el to control whether its global state should be persisted or not. (eshell-add-command-to-history): Don't write Eshell's history out to disk, let the governing mode control that upon exit. (eshell-add-input-to-history): New function, with most of the code from eshell-add-to-history. (eshell-add-command-to-history): New function, to record in eshell-history the commands run via eshell-command. (eshell-add-to-history): Call eshell-add-command-to-history to do most of the work.
-rw-r--r--lisp/eshell/em-hist.el56
1 files changed, 41 insertions, 15 deletions
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index a5426f53001..fb467f4ec7f 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -216,7 +216,8 @@ element, regardless of any text on the command line. In that case,
216 (add-hook 'pcomplete-try-first-hook 216 (add-hook 'pcomplete-try-first-hook
217 'eshell-complete-history-reference nil t)) 217 'eshell-complete-history-reference nil t))
218 218
219 (if (eshell-using-module 'eshell-rebind) 219 (if (and (eshell-using-module 'eshell-rebind)
220 (not eshell-non-interactive-p))
220 (let ((rebind-alist (symbol-value 'eshell-rebind-keys-alist))) 221 (let ((rebind-alist (symbol-value 'eshell-rebind-keys-alist)))
221 (make-local-variable 'eshell-rebind-keys-alist) 222 (make-local-variable 'eshell-rebind-keys-alist)
222 (set 'eshell-rebind-keys-alist 223 (set 'eshell-rebind-keys-alist
@@ -270,9 +271,16 @@ element, regardless of any text on the command line. In that case,
270 271
271 (make-local-variable 'eshell-history-index) 272 (make-local-variable 'eshell-history-index)
272 (make-local-variable 'eshell-save-history-index) 273 (make-local-variable 'eshell-save-history-index)
273 (make-local-variable 'eshell-history-ring) 274
274 (if eshell-history-file-name 275 (if (minibuffer-window-active-p (selected-window))
275 (eshell-read-history nil t)) 276 (set (make-local-variable 'eshell-ask-to-save-history) nil)
277 (set (make-local-variable 'eshell-history-ring) nil)
278 (if eshell-history-file-name
279 (eshell-read-history nil t))
280
281 (make-local-hook 'eshell-exit-hook)
282 (add-hook 'eshell-exit-hook 'eshell-write-history nil t))
283
276 (unless eshell-history-ring 284 (unless eshell-history-ring
277 (setq eshell-history-ring (make-ring eshell-history-size))) 285 (setq eshell-history-ring (make-ring eshell-history-size)))
278 286
@@ -360,22 +368,40 @@ unless a different file is specified on the command line.")
360 "Get an input line from the history ring." 368 "Get an input line from the history ring."
361 (ring-ref (or ring eshell-history-ring) index)) 369 (ring-ref (or ring eshell-history-ring) index))
362 370
363(defun eshell-add-to-history () 371(defun eshell-add-input-to-history (input)
364 "Add INPUT to the history ring. 372 "Add the string INPUT to the history ring.
365The input is entered into the input history ring, if the value of 373Input is entered into the input history ring, if the value of
366variable `eshell-input-filter' returns non-nil when called on the 374variable `eshell-input-filter' returns non-nil when called on the
367input." 375input."
376 (if (and (funcall eshell-input-filter input)
377 (or (null eshell-hist-ignoredups)
378 (not (ring-p eshell-history-ring))
379 (ring-empty-p eshell-history-ring)
380 (not (string-equal (eshell-get-history 0) input))))
381 (eshell-put-history input))
382 (setq eshell-save-history-index eshell-history-index)
383 (setq eshell-history-index nil))
384
385(defun eshell-add-command-to-history ()
386 "Add the command entered at `eshell-command's prompt to the history ring.
387The command is added to the input history ring, if the value of
388variable `eshell-input-filter' returns non-nil when called on the
389command.
390
391This function is supposed to be called from the minibuffer, presumably
392as a minibuffer-exit-hook."
393 (eshell-add-input-to-history
394 (buffer-substring (minibuffer-prompt-end) (point-max))))
395
396(defun eshell-add-to-history ()
397 "Add last Eshell command to the history ring.
398The command is entered into the input history ring, if the value of
399variable `eshell-input-filter' returns non-nil when called on the
400command."
368 (when (> (1- eshell-last-input-end) eshell-last-input-start) 401 (when (> (1- eshell-last-input-end) eshell-last-input-start)
369 (let ((input (buffer-substring eshell-last-input-start 402 (let ((input (buffer-substring eshell-last-input-start
370 (1- eshell-last-input-end)))) 403 (1- eshell-last-input-end))))
371 (if (and (funcall eshell-input-filter input) 404 (eshell-add-input-to-history input))))
372 (or (null eshell-hist-ignoredups)
373 (not (ring-p eshell-history-ring))
374 (ring-empty-p eshell-history-ring)
375 (not (string-equal (eshell-get-history 0) input))))
376 (eshell-put-history input))
377 (setq eshell-save-history-index eshell-history-index)
378 (setq eshell-history-index nil))))
379 405
380(defun eshell-read-history (&optional filename silent) 406(defun eshell-read-history (&optional filename silent)
381 "Sets the buffer's `eshell-history-ring' from a history file. 407 "Sets the buffer's `eshell-history-ring' from a history file.