aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/shell.el
diff options
context:
space:
mode:
authorAndrew Innes2000-09-14 21:15:44 +0000
committerAndrew Innes2000-09-14 21:15:44 +0000
commit4dced9273615d7c3d7462368b32cb541d04e5aef (patch)
treefec92c54f500a6252ccd89d68ddc260da8ec156d /lisp/shell.el
parent1198514be7faa6b137174b8e4e5df117277ddf50 (diff)
downloademacs-4dced9273615d7c3d7462368b32cb541d04e5aef.tar.gz
emacs-4dced9273615d7c3d7462368b32cb541d04e5aef.zip
(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.el27
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 @@
121 :group 'shell) 121 :group 'shell)
122 122
123;;;###autoload 123;;;###autoload
124(defcustom shell-dumb-shell-regexp "cmd\\(proxy\\)?\\.exe"
125 "Regexp to match shells that don't save their command history.
126For shells that match this regexp, Emacs will write out the
127command history when the shell finishes."
128 :type 'regexp
129 :group 'shell)
130
124(defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" 131(defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *"
125 "Regexp to match prompts in the inferior shell. 132 "Regexp to match prompts in the inferior shell.
126Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. 133Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well.
@@ -421,12 +428,32 @@ buffer."
421 (equal (file-truename comint-input-ring-file-name) 428 (equal (file-truename comint-input-ring-file-name)
422 (file-truename "/dev/null"))) 429 (file-truename "/dev/null")))
423 (setq comint-input-ring-file-name nil)) 430 (setq comint-input-ring-file-name nil))
431 ;; Arrange to write out the input ring on exit, if the shell doesn't
432 ;; do this itself.
433 (if (and comint-input-ring-file-name
434 (string-match shell-dumb-shell-regexp shell))
435 (set-process-sentinel (get-buffer-process (current-buffer))
436 #'shell-write-history-on-exit))
424 (setq shell-dirstack-query 437 (setq shell-dirstack-query
425 (cond ((string-equal shell "sh") "pwd") 438 (cond ((string-equal shell "sh") "pwd")
426 ((string-equal shell "ksh") "echo $PWD ~-") 439 ((string-equal shell "ksh") "echo $PWD ~-")
427 (t "dirs")))) 440 (t "dirs"))))
428 (run-hooks 'shell-mode-hook) 441 (run-hooks 'shell-mode-hook)
429 (comint-read-input-ring t)) 442 (comint-read-input-ring t))
443
444(defun shell-write-history-on-exit (process event)
445 "Called when the shell process is stopped.
446
447Writes the input history to a history file
448`comint-comint-input-ring-file-name' using `comint-write-input-ring'
449and inserts a short message in the shell buffer.
450
451This function is a sentinel watching the shell interpreter process.
452Sentinels will always get the two parameters PROCESS and EVENT."
453 ;; Write history.
454 (comint-write-input-ring)
455 (if (buffer-live-p (process-buffer process))
456 (insert (format "\nProcess %s %s\n" process event))))
430 457
431;;;###autoload 458;;;###autoload
432(defun shell () 459(defun shell ()