diff options
author | Andrew Innes <andrewi@gnu.org> | 2000-09-14 21:15:44 +0000 |
---|---|---|
committer | Andrew Innes <andrewi@gnu.org> | 2000-09-14 21:15:44 +0000 |
commit | 4dced9273615d7c3d7462368b32cb541d04e5aef (patch) | |
tree | fec92c54f500a6252ccd89d68ddc260da8ec156d /lisp/shell.el | |
parent | 1198514be7faa6b137174b8e4e5df117277ddf50 (diff) | |
download | emacs-4dced9273615d7c3d7462368b32cb541d04e5aef.tar.gz |
(shell-write-history-on-exit): New function.
(shell-dumb-shell-regexp): New custom variable.
(shell-mode): Make shell-write-history-on-exit the process
sentinel if shell name matches shell-dumb-shell-regexp.
Diffstat (limited to 'lisp/shell.el')
-rw-r--r-- | lisp/shell.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index ea0251bb1da..b7c27b7778a 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -121,6 +121,13 @@ :group 'shell) ;;;###autoload +(defcustom shell-dumb-shell-regexp "cmd\\(proxy\\)?\\.exe" + "Regexp to match shells that don't save their command history. +For shells that match this regexp, Emacs will write out the +command history when the shell finishes." + :type 'regexp + :group 'shell) + (defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" "Regexp to match prompts in the inferior shell. Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. @@ -421,12 +428,32 @@ buffer." (equal (file-truename comint-input-ring-file-name) (file-truename "/dev/null"))) (setq comint-input-ring-file-name nil)) + ;; Arrange to write out the input ring on exit, if the shell doesn't + ;; do this itself. + (if (and comint-input-ring-file-name + (string-match shell-dumb-shell-regexp shell)) + (set-process-sentinel (get-buffer-process (current-buffer)) + #'shell-write-history-on-exit)) (setq shell-dirstack-query (cond ((string-equal shell "sh") "pwd") ((string-equal shell "ksh") "echo $PWD ~-") (t "dirs")))) (run-hooks 'shell-mode-hook) (comint-read-input-ring t)) + +(defun shell-write-history-on-exit (process event) + "Called when the shell process is stopped. + +Writes the input history to a history file +`comint-comint-input-ring-file-name' using `comint-write-input-ring' +and inserts a short message in the shell buffer. + +This function is a sentinel watching the shell interpreter process. +Sentinels will always get the two parameters PROCESS and EVENT." + ;; Write history. + (comint-write-input-ring) + (if (buffer-live-p (process-buffer process)) + (insert (format "\nProcess %s %s\n" process event)))) ;;;###autoload (defun shell () |