aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2001-01-28 03:43:35 +0000
committerSam Steingold2001-01-28 03:43:35 +0000
commit847285704da07e3bf5526b6bd373ba1fe193ec35 (patch)
treea56be6657620224fe644813f73dcddce9b822f8d
parent8d04974a78b0081de2436d3cc06033d927a7b6e1 (diff)
downloademacs-847285704da07e3bf5526b6bd373ba1fe193ec35.tar.gz
emacs-847285704da07e3bf5526b6bd373ba1fe193ec35.zip
shell-write-history-on-exit: make sure the error message goes to the right buffer
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/shell.el50
2 files changed, 35 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index db5f1a5b95a..3662a6a1d5c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,10 +1,16 @@
12001-01-27 Sam Steingold <sds@gnu.org>
2
3 * shell.el (shell-write-history-on-exit): Make sure that we are in
4 the shell buffer (M-x tex-file RET inserted the error message into
5 the TeX buffer).
6
12001-01-27 Eli Zaretskii <eliz@is.elta.co.il> 72001-01-27 Eli Zaretskii <eliz@is.elta.co.il>
2 8
3 * simple.el (transient-mark-mode): Doc fix. 9 * simple.el (transient-mark-mode): Doc fix.
4 10
52001-01-27 Gerd Moellmann <gerd@gnu.org> 112001-01-27 Gerd Moellmann <gerd@gnu.org>
6 12
7 * progmodes/etags.el (find-tag-noselect): Don't bind 13 * progmodes/etags.el (find-tag-noselect): Don't bind
8 tags-file-name. 14 tags-file-name.
9 15
102001-01-27 Eli Zaretskii <eliz@is.elta.co.il> 162001-01-27 Eli Zaretskii <eliz@is.elta.co.il>
@@ -22,7 +28,7 @@
22 28
232001-01-27 Richard M. Stallman <rms@caffeine.ai.mit.edu> 292001-01-27 Richard M. Stallman <rms@caffeine.ai.mit.edu>
24 30
25 * dabbrev.el (dabbrev--substitute-expansion): 31 * dabbrev.el (dabbrev--substitute-expansion):
26 Treat a one-capital-letter abbrev as "not all upper case", 32 Treat a one-capital-letter abbrev as "not all upper case",
27 so as to force preservation of the expansion's pattern 33 so as to force preservation of the expansion's pattern
28 if the expansion starts with a capital letter. 34 if the expansion starts with a capital letter.
@@ -49,7 +55,7 @@
49 55
50 * time-stamp.el: Doc fixes. 56 * time-stamp.el: Doc fixes.
51 57
52 * progmodes/delphi.el (delphi-comment-face, delphi-string-face) 58 * progmodes/delphi.el (delphi-comment-face, delphi-string-face)
53 (delphi-keyword-face, delphi-other-face): Fix :type. 59 (delphi-keyword-face, delphi-other-face): Fix :type.
54 60
55 * textmodes/flyspell.el: Doc fixes. Add :version to new options. 61 * textmodes/flyspell.el: Doc fixes. Add :version to new options.
diff --git a/lisp/shell.el b/lisp/shell.el
index e0052e57c8a..43b7f6ab064 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -37,7 +37,7 @@
37;; featureful, robust, and uniform than the Emacs 18 version. 37;; featureful, robust, and uniform than the Emacs 18 version.
38 38
39;; Since this mode is built on top of the general command-interpreter-in- 39;; Since this mode is built on top of the general command-interpreter-in-
40;; a-buffer mode (comint mode), it shares a common base functionality, 40;; a-buffer mode (comint mode), it shares a common base functionality,
41;; and a common set of bindings, with all modes derived from comint mode. 41;; and a common set of bindings, with all modes derived from comint mode.
42;; This makes these modes easier to use. 42;; This makes these modes easier to use.
43 43
@@ -46,7 +46,7 @@
46;; For further information on shell mode, see the comments below. 46;; For further information on shell mode, see the comments below.
47 47
48;; Needs fixin: 48;; Needs fixin:
49;; When sending text from a source file to a subprocess, the process-mark can 49;; When sending text from a source file to a subprocess, the process-mark can
50;; move off the window, so you can lose sight of the process interactions. 50;; move off the window, so you can lose sight of the process interactions.
51;; Maybe I should ensure the process mark is in the window when I send 51;; Maybe I should ensure the process mark is in the window when I send
52;; text to the process? Switch selectable? 52;; text to the process? Switch selectable?
@@ -58,7 +58,7 @@
58;; ;; Define M-# to run some strange command: 58;; ;; Define M-# to run some strange command:
59;; (eval-after-load "shell" 59;; (eval-after-load "shell"
60;; '(define-key shell-mode-map "\M-#" 'shells-dynamic-spell)) 60;; '(define-key shell-mode-map "\M-#" 'shells-dynamic-spell))
61 61
62;; Brief Command Documentation: 62;; Brief Command Documentation:
63;;============================================================================ 63;;============================================================================
64;; Comint Mode Commands: (common to shell and all comint-derived modes) 64;; Comint Mode Commands: (common to shell and all comint-derived modes)
@@ -100,7 +100,7 @@
100;; compatibility. 100;; compatibility.
101 101
102;; Read the rest of this file for more information. 102;; Read the rest of this file for more information.
103 103
104;;; Code: 104;;; Code:
105 105
106(require 'comint) 106(require 'comint)
@@ -133,7 +133,7 @@ arguments."
133(defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" 133(defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *"
134 "Regexp to match prompts in the inferior shell. 134 "Regexp to match prompts in the inferior shell.
135Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. 135Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well.
136This variable is used to initialise `comint-prompt-regexp' in the 136This variable is used to initialise `comint-prompt-regexp' in the
137shell buffer. 137shell buffer.
138 138
139This variable is only used if the variable 139This variable is only used if the variable
@@ -244,7 +244,7 @@ This mirrors the optional behavior of tcsh."
244 :group 'shell-directories) 244 :group 'shell-directories)
245 245
246(defcustom shell-chdrive-regexp 246(defcustom shell-chdrive-regexp
247 (if (memq system-type '(ms-dos windows-nt)) 247 (if (memq system-type '(ms-dos windows-nt))
248 ; NetWare allows the five chars between upper and lower alphabetics. 248 ; NetWare allows the five chars between upper and lower alphabetics.
249 "[]a-zA-Z^_`\\[\\\\]:" 249 "[]a-zA-Z^_`\\[\\\\]:"
250 nil) 250 nil)
@@ -334,7 +334,7 @@ Thus, this does not include the shell's current directory.")
334 ("^[^ \t\n]+:.*" . font-lock-string-face) 334 ("^[^ \t\n]+:.*" . font-lock-string-face)
335 ("^\\[[1-9][0-9]*\\]" . font-lock-string-face)) 335 ("^\\[[1-9][0-9]*\\]" . font-lock-string-face))
336 "Additional expressions to highlight in Shell mode.") 336 "Additional expressions to highlight in Shell mode.")
337 337
338;;; Basic Procedures 338;;; Basic Procedures
339 339
340(put 'shell-mode 'mode-class 'special) 340(put 'shell-mode 'mode-class 'special)
@@ -362,7 +362,7 @@ to continue it.
362keep this buffer's default directory the same as the shell's working directory. 362keep this buffer's default directory the same as the shell's working directory.
363While directory tracking is enabled, the shell's working directory is displayed 363While directory tracking is enabled, the shell's working directory is displayed
364by \\[list-buffers] or \\[mouse-buffer-menu] in the `File' field. 364by \\[list-buffers] or \\[mouse-buffer-menu] in the `File' field.
365\\[dirs] queries the shell and resyncs Emacs' idea of what the current 365\\[dirs] queries the shell and resyncs Emacs' idea of what the current
366 directory stack is. 366 directory stack is.
367\\[dirtrack-mode] turns directory tracking on and off. 367\\[dirtrack-mode] turns directory tracking on and off.
368 368
@@ -372,9 +372,9 @@ Customization: Entry to this mode runs the hooks on `comint-mode-hook' and
372`comint-input-filter-functions' are run. After each shell output, the hooks 372`comint-input-filter-functions' are run. After each shell output, the hooks
373on `comint-output-filter-functions' are run. 373on `comint-output-filter-functions' are run.
374 374
375Variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp' 375Variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp'
376and `shell-popd-regexp' are used to match their respective commands, 376and `shell-popd-regexp' are used to match their respective commands,
377while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique' 377while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique'
378control the behavior of the relevant command. 378control the behavior of the relevant command.
379 379
380Variables `comint-completion-autolist', `comint-completion-addsuffix', 380Variables `comint-completion-autolist', `comint-completion-addsuffix',
@@ -441,16 +441,18 @@ buffer."
441 "Called when the shell process is stopped. 441 "Called when the shell process is stopped.
442 442
443Writes the input history to a history file 443Writes the input history to a history file
444`comint-comint-input-ring-file-name' using `comint-write-input-ring' 444`comint-input-ring-file-name' using `comint-write-input-ring'
445and inserts a short message in the shell buffer. 445and inserts a short message in the shell buffer.
446 446
447This function is a sentinel watching the shell interpreter process. 447This function is a sentinel watching the shell interpreter process.
448Sentinels will always get the two parameters PROCESS and EVENT." 448Sentinels will always get the two parameters PROCESS and EVENT."
449 ;; Write history. 449 ;; Write history.
450 (comint-write-input-ring) 450 (comint-write-input-ring)
451 (if (buffer-live-p (process-buffer process)) 451 (let ((buf (process-buffer process)))
452 (insert (format "\nProcess %s %s\n" process event)))) 452 (when (buffer-live-p buf)
453 453 (with-current-buffer buf
454 (insert (format "\nProcess %s %s\n" process event))))))
455
454;;;###autoload 456;;;###autoload
455(defun shell (&optional buffer) 457(defun shell (&optional buffer)
456 "Run an inferior shell, with I/O through BUFFER (which defaults to `*shell*'). 458 "Run an inferior shell, with I/O through BUFFER (which defaults to `*shell*').
@@ -490,7 +492,7 @@ Otherwise, one argument `-i' is passed to the shell.
490 (let* ((prog (or explicit-shell-file-name 492 (let* ((prog (or explicit-shell-file-name
491 (getenv "ESHELL") 493 (getenv "ESHELL")
492 (getenv "SHELL") 494 (getenv "SHELL")
493 "/bin/sh")) 495 "/bin/sh"))
494 (name (file-name-nondirectory prog)) 496 (name (file-name-nondirectory prog))
495 (startfile (concat "~/.emacs_" name)) 497 (startfile (concat "~/.emacs_" name))
496 (xargs-name (intern-soft (concat "explicit-" name "-args"))) 498 (xargs-name (intern-soft (concat "explicit-" name "-args")))
@@ -508,7 +510,7 @@ Otherwise, one argument `-i' is passed to the shell.
508 510
509;;; Don't do this when shell.el is loaded, only while dumping. 511;;; Don't do this when shell.el is loaded, only while dumping.
510;;;###autoload (add-hook 'same-window-buffer-names "*shell*") 512;;;###autoload (add-hook 'same-window-buffer-names "*shell*")
511 513
512;;; Directory tracking 514;;; Directory tracking
513;;; 515;;;
514;;; This code provides the shell mode input sentinel 516;;; This code provides the shell mode input sentinel
@@ -537,7 +539,7 @@ Otherwise, one argument `-i' is passed to the shell.
537;;; 539;;;
538;;; The solution is to relax, not stress out about it, and settle for 540;;; The solution is to relax, not stress out about it, and settle for
539;;; a hack that works pretty well in typical circumstances. Remember 541;;; a hack that works pretty well in typical circumstances. Remember
540;;; that a half-assed solution is more in keeping with the spirit of Unix, 542;;; that a half-assed solution is more in keeping with the spirit of Unix,
541;;; anyway. Blech. 543;;; anyway. Blech.
542;;; 544;;;
543;;; One good hack not implemented here for users of programmable shells 545;;; One good hack not implemented here for users of programmable shells
@@ -559,7 +561,7 @@ You may toggle this tracking on and off with M-x dirtrack-mode.
559If emacs gets confused, you can resync with the shell with M-x dirs. 561If emacs gets confused, you can resync with the shell with M-x dirs.
560 562
561See variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp', 563See variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp',
562and `shell-popd-regexp', while `shell-pushd-tohome', `shell-pushd-dextract', 564and `shell-popd-regexp', while `shell-pushd-tohome', `shell-pushd-dextract',
563and `shell-pushd-dunique' control the behavior of the relevant command. 565and `shell-pushd-dunique' control the behavior of the relevant command.
564 566
565Environment variables are expanded, see function `substitute-in-file-name'." 567Environment variables are expanded, see function `substitute-in-file-name'."
@@ -729,7 +731,7 @@ Environment variables are expanded, see function `substitute-in-file-name'."
729 731
730(defun shell-resync-dirs () 732(defun shell-resync-dirs ()
731 "Resync the buffer's idea of the current directory stack. 733 "Resync the buffer's idea of the current directory stack.
732This command queries the shell with the command bound to 734This command queries the shell with the command bound to
733`shell-dirstack-query' (default \"dirs\"), reads the next 735`shell-dirstack-query' (default \"dirs\"), reads the next
734line output and parses it to form the new directory stack. 736line output and parses it to form the new directory stack.
735DON'T issue this command unless the buffer is at a shell prompt. 737DON'T issue this command unless the buffer is at a shell prompt.
@@ -743,7 +745,7 @@ command again."
743 (goto-char pmark) 745 (goto-char pmark)
744 (insert shell-dirstack-query) (insert "\n") 746 (insert shell-dirstack-query) (insert "\n")
745 (sit-for 0) ; force redisplay 747 (sit-for 0) ; force redisplay
746 (comint-send-string proc shell-dirstack-query) 748 (comint-send-string proc shell-dirstack-query)
747 (comint-send-string proc "\n") 749 (comint-send-string proc "\n")
748 (set-marker pmark (point)) 750 (set-marker pmark (point))
749 (let ((pt (point))) ; wait for 1 line 751 (let ((pt (point))) ; wait for 1 line
@@ -804,7 +806,7 @@ command again."
804 (setq msg (concat msg (directory-file-name dir) " ")) 806 (setq msg (concat msg (directory-file-name dir) " "))
805 (setq ds (cdr ds)))) 807 (setq ds (cdr ds))))
806 (message "%s" msg)))) 808 (message "%s" msg))))
807 809
808;; This was mostly copied from shell-resync-dirs. 810;; This was mostly copied from shell-resync-dirs.
809(defun shell-snarf-envar (var) 811(defun shell-snarf-envar (var)
810 "Return as a string the shell's value of environment variable VAR." 812 "Return as a string the shell's value of environment variable VAR."
@@ -835,7 +837,7 @@ from Emacs."
835 (interactive (list (read-envvar-name "\ 837 (interactive (list (read-envvar-name "\
836Copy Shell environment variable to Emacs: "))) 838Copy Shell environment variable to Emacs: ")))
837 (setenv variable (shell-snarf-envar variable))) 839 (setenv variable (shell-snarf-envar variable)))
838 840
839(defun shell-forward-command (&optional arg) 841(defun shell-forward-command (&optional arg)
840 "Move forward across ARG shell command(s). Does not cross lines. 842 "Move forward across ARG shell command(s). Does not cross lines.
841See `shell-command-regexp'." 843See `shell-command-regexp'."
@@ -1006,7 +1008,7 @@ Returns t if successful."
1006 (replace-match (file-name-as-directory (nth index stack)) t t) 1008 (replace-match (file-name-as-directory (nth index stack)) t t)
1007 (message "Directory item: %d" index) 1009 (message "Directory item: %d" index)
1008 t)))))) 1010 t))))))
1009 1011
1010(provide 'shell) 1012(provide 'shell)
1011 1013
1012;;; shell.el ends here 1014;;; shell.el ends here