annotate lisp/comint.el @ 2522:c93900809245

(rot13-other-window): Add autoload.
author Richard M. Stallman <rms@gnu.org>
date Mon, 12 Apr 1993 07:49:31 +0000
parents 10509afe2588
children 577c77cfd199
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 638
diff changeset
1 ;;; comint.el --- general command interpreter in a window stuff
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
2
1839
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
3 ;; Copyright (C) 1988, 1990, 1992, 1993 Free Software Foundation, Inc.
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 638
diff changeset
4
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
5 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2025
diff changeset
6 ;; Keywords: processes
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
7
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
8 ;; This file is part of GNU Emacs.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
9
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
13 ;; any later version.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
14
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
18 ;; GNU General Public License for more details.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
19
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
20 ;; You should have received a copy of the GNU General Public License
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
24 ;;; Commentary:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
25
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
26 ;;; The changelog is at the end of this file.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
27
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
28 ;;; Please send me bug reports, bug fixes, and extensions, so that I can
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
29 ;;; merge them into the master source.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
30 ;;; - Olin Shivers (shivers@cs.cmu.edu)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
31
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
32 ;;; This file defines a general command-interpreter-in-a-buffer package
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
33 ;;; (comint mode). The idea is that you can build specific process-in-a-buffer
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
34 ;;; modes on top of comint mode -- e.g., lisp, shell, scheme, T, soar, ....
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
35 ;;; This way, all these specific packages share a common base functionality,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
36 ;;; and a common set of bindings, which makes them easier to use (and
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
37 ;;; saves code, implementation time, etc., etc.).
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
38
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
39 ;;; Several packages are already defined using comint mode:
2518
10509afe2588 Clean up cmu* uses in header comments.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2455
diff changeset
40 ;;; - shell.el defines a shell-in-a-buffer mode.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
41 ;;; - cmulisp.el defines a simple lisp-in-a-buffer mode.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
42 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
43 ;;; - The file cmuscheme.el defines a scheme-in-a-buffer mode.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
44 ;;; - The file tea.el tunes scheme and inferior-scheme modes for T.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
45 ;;; - The file soar.el tunes lisp and inferior-lisp modes for Soar.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
46 ;;; - cmutex.el defines tex and latex modes that invoke tex, latex, bibtex,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
47 ;;; previewers, and printers from within emacs.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
48 ;;; - background.el allows csh-like job control inside emacs.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
49 ;;; It is pretty easy to make new derived modes for other processes.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
50
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
51 ;;; For documentation on the functionality provided by comint mode, and
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
52 ;;; the hooks available for customising it, see the comments below.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
53 ;;; For further information on the standard derived modes (shell,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
54 ;;; inferior-lisp, inferior-scheme, ...), see the relevant source files.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
55
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
56 ;;; For hints on converting existing process modes (e.g., tex-mode,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
57 ;;; background, dbx, gdb, kermit, prolog, telnet) to use comint-mode
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
58 ;;; instead of shell-mode, see the notes at the end of this file.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
59
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
60
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
61 ;;; Brief Command Documentation:
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
62 ;;;============================================================================
2518
10509afe2588 Clean up cmu* uses in header comments.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2455
diff changeset
63 ;;; Comint Mode Commands: (common to all derived modes, like shell & cmulisp
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
64 ;;; mode)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
65 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
66 ;;; m-p comint-previous-input Cycle backwards in input history
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
67 ;;; m-n comint-next-input Cycle forwards
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
68 ;;; m-r comint-previous-similar-input Previous similar input
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
69 ;;; m-s comint-next-similar-input Next similar input
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
70 ;;; c-m-r comint-previous-input-matching Search backwards in input history
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
71 ;;; return comint-send-input
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
72 ;;; c-a comint-bol Beginning of line; skip prompt.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
73 ;;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
74 ;;; c-c c-u comint-kill-input ^u
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
75 ;;; c-c c-w backward-kill-word ^w
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
76 ;;; c-c c-c comint-interrupt-subjob ^c
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
77 ;;; c-c c-z comint-stop-subjob ^z
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
78 ;;; c-c c-\ comint-quit-subjob ^\
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
79 ;;; c-c c-o comint-kill-output Delete last batch of process output
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
80 ;;; c-c c-r comint-show-output Show last batch of process output
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
81 ;;;
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
82 ;;; Not bound by default in comint-mode
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
83 ;;; send-invisible Read a line w/o echo, and send to proc
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
84 ;;; (These are bound in shell-mode)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
85 ;;; comint-dynamic-complete Complete filename at point.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
86 ;;; comint-dynamic-list-completions List completions in help buffer.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
87 ;;; comint-replace-by-expanded-filename Expand and complete filename at point;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
88 ;;; replace with expanded/completed name.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
89 ;;; comint-kill-subjob No mercy.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
90 ;;; comint-continue-subjob Send CONT signal to buffer's process
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
91 ;;; group. Useful if you accidentally
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
92 ;;; suspend your process (with C-c C-z).
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
93 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
94 ;;; These used to be bound for RMS -- I prefer the input history stuff,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
95 ;;; but you might like 'em.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
96 ;;; m-P comint-msearch-input Search backwards for prompt
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
97 ;;; m-N comint-psearch-input Search forwards for prompt
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
98 ;;; C-cR comint-msearch-input-matching Search backwards for prompt & string
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
99
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
100 ;;; comint-mode-hook is the comint mode hook. Basically for your keybindings.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
101 ;;; comint-load-hook is run after loading in this package.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
102
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
103 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
104
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
105 (defconst comint-version "2.03")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
106
1131
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
107 (require 'ring)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
108
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
109 ;;; Buffer Local Variables:
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
110 ;;;============================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
111 ;;; Comint mode buffer local variables:
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
112 ;;; comint-prompt-regexp - string comint-bol uses to match prompt.
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
113 ;;; comint-last-input-start - marker Handy if inferior always echos
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
114 ;;; comint-last-input-end - marker For comint-kill-output command
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
115 ;;; comint-input-ring-size - integer For the input history
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
116 ;;; comint-input-ring - ring mechanism
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
117 ;;; comint-input-ring-index - marker ...
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
118 ;;; comint-last-input-match - string ...
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
119 ;;; comint-get-old-input - function Hooks for specific
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
120 ;;; comint-input-sentinel - function process-in-a-buffer
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
121 ;;; comint-input-filter - function modes.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
122 ;;; comint-input-send - function
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
123 ;;; comint-eol-on-send - boolean
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
124
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
125 (defvar comint-prompt-regexp "^"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
126 "Regexp to recognise prompts in the inferior process.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
127 Defaults to \"^\", the null string at BOL.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
128
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
129 Good choices:
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
130 Canonical Lisp: \"^[^> ]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
131 Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
132 franz: \"^\\(->\\|<[0-9]*>:\\) *\"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
133 kcl: \"^>+ *\"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
134 shell: \"^[^#$%>]*[#$%>] *\"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
135 T: \"^>+ *\"
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
136
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
137 This is a good thing to set in mode hooks.")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
138
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
139 (defvar comint-input-ring-size 30
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
140 "Size of input history ring.")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
141
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
142 ;;; Here are the per-interpreter hooks.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
143 (defvar comint-get-old-input (function comint-get-old-input-default)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
144 "Function that submits old text in comint mode.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
145 This function is called when return is typed while the point is in old text.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
146 It returns the text to be submitted as process input. The default is
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
147 comint-get-old-input-default, which grabs the current line, and strips off
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
148 leading text matching comint-prompt-regexp")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
149
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
150 (defvar comint-input-sentinel (function ignore)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
151 "Called on each input submitted to comint mode process by comint-send-input.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
152 Thus it can, for instance, track cd/pushd/popd commands issued to the csh.")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
153
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
154 (defvar comint-input-filter
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
155 (function (lambda (str) (not (string-match "\\`\\s *\\'" str))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
156 "Predicate for filtering additions to input history.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
157 Only inputs answering true to this function are saved on the input
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
158 history list. Default is to save anything that isn't all whitespace")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
159
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
160 (defvar comint-input-sender (function comint-simple-send)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
161 "Function to actually send to PROCESS the STRING submitted by user.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
162 Usually this is just 'comint-simple-send, but if your mode needs to
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
163 massage the input string, this is your hook. This is called from
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
164 the user command comint-send-input. comint-simple-send just sends
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
165 the string plus a newline.")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
166
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
167 (defvar comint-eol-on-send 'T
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
168 "If non-nil, then jump to the end of the line before sending input to process.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
169 See comint-send-input")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
170
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
171 (defvar comint-mode-hook '()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
172 "Called upon entry into comint-mode
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
173 This is run before the process is cranked up.")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
174
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
175 (defvar comint-exec-hook '()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
176 "Called each time a process is exec'd by comint-exec.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
177 This is called after the process is cranked up. It is useful for things that
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
178 must be done each time a process is executed in a comint-mode buffer (e.g.,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
179 (process-kill-without-query)). In contrast, the comint-mode-hook is only
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
180 executed once when the buffer is created.")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
181
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
182 (defvar comint-mode-map nil)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
183
1131
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
184 (defvar comint-ptyp t
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
185 "True if communications via pty; false if by pipe. Buffer local.
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
186 This is to work around a bug in emacs process signalling.")
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
187
1376
dd83ec6103fe (comint-last-input-match): defvar moved up.
Richard M. Stallman <rms@gnu.org>
parents: 1373
diff changeset
188 (defvar comint-last-input-match ""
dd83ec6103fe (comint-last-input-match): defvar moved up.
Richard M. Stallman <rms@gnu.org>
parents: 1373
diff changeset
189 "Last string searched for by comint input history search, for defaulting.
dd83ec6103fe (comint-last-input-match): defvar moved up.
Richard M. Stallman <rms@gnu.org>
parents: 1373
diff changeset
190 Buffer local variable.")
dd83ec6103fe (comint-last-input-match): defvar moved up.
Richard M. Stallman <rms@gnu.org>
parents: 1373
diff changeset
191
932
a93f0b1ba909 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 925
diff changeset
192 (defvar comint-input-ring nil)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
193 (defvar comint-last-input-start)
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
194 (defvar comint-last-input-end)
1131
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
195 (defvar comint-input-ring-index)
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
196 (put 'comint-input-ring 'permanent-local t)
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
197 (put 'comint-ptyp 'permanent-local t)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
198
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
199 (defun comint-mode ()
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
200 "Major mode for interacting with an inferior interpreter.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
201 Interpreter name is same as buffer name, sans the asterisks.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
202 Return at end of buffer sends line as input.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
203 Return not at end copies rest of line to end and sends it.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
204 Setting mode variable comint-eol-on-send means jump to the end of the line
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
205 before submitting new input.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
206
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
207 This mode is typically customised to create inferior-lisp-mode,
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
208 shell-mode, etc.. This can be done by setting the hooks
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
209 comint-input-sentinel, comint-input-filter, comint-input-sender and
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
210 comint-get-old-input to appropriate functions, and the variable
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
211 comint-prompt-regexp to the appropriate regular expression.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
212
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
213 An input history is maintained of size comint-input-ring-size, and
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
214 can be accessed with the commands comint-next-input [\\[comint-next-input]] and
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
215 comint-previous-input [\\[comint-previous-input]]. Commands not keybound by
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
216 default are send-invisible, comint-dynamic-complete, and
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
217 comint-list-dynamic-completions.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
218
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
219 If you accidentally suspend your process, use \\[comint-continue-subjob]
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
220 to continue it.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
221
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
222 \\{comint-mode-map}
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
223
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
224 Entry to this mode runs the hooks on comint-mode-hook"
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
225 (interactive)
1131
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
226 ;; Do not remove this. All major modes must do this.
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
227 (kill-all-local-variables)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
228 (setq major-mode 'comint-mode)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
229 (setq mode-name "Comint")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
230 (setq mode-line-process '(": %s"))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
231 (use-local-map comint-mode-map)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
232 (make-local-variable 'comint-last-input-start)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
233 (setq comint-last-input-start (make-marker))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
234 (make-local-variable 'comint-last-input-end)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
235 (setq comint-last-input-end (make-marker))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
236 (make-local-variable 'comint-last-input-match)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
237 (setq comint-last-input-match "")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
238 (make-local-variable 'comint-prompt-regexp) ; Don't set; default
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
239 (make-local-variable 'comint-input-ring-size) ; ...to global val.
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
240 (make-local-variable 'comint-input-ring)
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
241 (make-local-variable 'comint-input-ring-index)
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
242 (setq comint-input-ring-index 0)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
243 (make-local-variable 'comint-get-old-input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
244 (make-local-variable 'comint-input-sentinel)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
245 (make-local-variable 'comint-input-filter)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
246 (make-local-variable 'comint-input-sender)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
247 (make-local-variable 'comint-eol-on-send)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
248 (make-local-variable 'comint-ptyp)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
249 (make-local-variable 'comint-exec-hook)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
250 (run-hooks 'comint-mode-hook)
1131
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
251 (or comint-input-ring
853d0d4c61fb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 932
diff changeset
252 (setq comint-input-ring (make-ring comint-input-ring-size))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
253
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
254 (if comint-mode-map
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
255 nil
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
256 (setq comint-mode-map (make-sparse-keymap))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
257 (define-key comint-mode-map "\ep" 'comint-previous-input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
258 (define-key comint-mode-map "\en" 'comint-next-input)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
259 (define-key comint-mode-map "\er" 'comint-previous-similar-input)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
260 (define-key comint-mode-map "\es" 'comint-next-similar-input)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
261 (define-key comint-mode-map "\C-m" 'comint-send-input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
262 (define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
263 (define-key comint-mode-map "\C-a" 'comint-bol)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
264 (define-key comint-mode-map "\C-c\C-u" 'comint-kill-input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
265 (define-key comint-mode-map "\C-c\C-w" 'backward-kill-word)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
266 (define-key comint-mode-map "\C-c\C-c" 'comint-interrupt-subjob)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
267 (define-key comint-mode-map "\C-c\C-z" 'comint-stop-subjob)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
268 (define-key comint-mode-map "\C-c\C-\\" 'comint-quit-subjob)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
269 (define-key comint-mode-map "\C-c\C-o" 'comint-kill-output)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
270 (define-key comint-mode-map "\C-\M-r" 'comint-previous-input-matching)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
271 (define-key comint-mode-map "\C-c\C-r" 'comint-show-output)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
272 ;;; prompt-search commands commented out 3/90 -Olin
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
273 ; (define-key comint-mode-map "\eP" 'comint-msearch-input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
274 ; (define-key comint-mode-map "\eN" 'comint-psearch-input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
275 ; (define-key comint-mode-map "\C-cR" 'comint-msearch-input-matching)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
276 )
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
277
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
278
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
279 ;;; This function is used to make a full copy of the comint mode map,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
280 ;;; so that client modes won't interfere with each other. This function
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
281 ;;; isn't necessary in emacs 18.5x, but we keep it around for 18.4x versions.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
282 (defun full-copy-sparse-keymap (km)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
283 "Recursively copy the sparse keymap KM"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
284 (cond ((consp km)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
285 (cons (full-copy-sparse-keymap (car km))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
286 (full-copy-sparse-keymap (cdr km))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
287 (t km)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
288
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
289 (defun comint-check-proc (buffer)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
290 "True if there is a process associated w/buffer BUFFER, and
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
291 it is alive (status RUN or STOP). BUFFER can be either a buffer or the
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
292 name of one"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
293 (let ((proc (get-buffer-process buffer)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
294 (and proc (memq (process-status proc) '(run stop)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
295
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
296 ;;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it ()
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
297 ;;; for the second argument (program).
870
1b3af6ad85be *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 864
diff changeset
298 ;;;###autoload
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
299 (defun make-comint (name program &optional startfile &rest switches)
1839
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
300 "Make a comint process NAME in a buffer, running PROGRAM.
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
301 The name of the buffer is made by surrounding NAME with `*'s.
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
302 If there is already a running process in that buffer, it is not restarted.
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
303 Optional third arg STARTFILE is the name of a file to send the contents of to
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
304 the process. Any more args are arguments to PROGRAM."
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
305 (let ((buffer (get-buffer-create (concat "*" name "*"))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
306 ;; If no process, or nuked process, crank up a new one and put buffer in
1839
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
307 ;; comint mode. Otherwise, leave buffer and existing process alone.
182
35ea4993d08c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
308 (cond ((not (comint-check-proc buffer))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
309 (save-excursion
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
310 (set-buffer buffer)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
311 (comint-mode)) ; Install local vars, mode, keymap, ...
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
312 (comint-exec buffer name program startfile switches)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
313 buffer))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
314
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
315 (defun comint-exec (buffer name command startfile switches)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
316 "Fires up a process in buffer for comint modes.
1839
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
317 Blasts any old process running in the buffer. Doesn't set the buffer mode.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
318 You can use this to cheaply run a series of processes in the same comint
1839
e10cdcb857d2 (make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents: 1821
diff changeset
319 buffer. The hook comint-exec-hook is run after each exec."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
320 (save-excursion
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
321 (set-buffer buffer)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
322 (let ((proc (get-buffer-process buffer))) ; Blast any old process.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
323 (if proc (delete-process proc)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
324 ;; Crank up a new process
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
325 (let ((proc (comint-exec-1 name buffer command switches)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
326 (make-local-variable 'comint-ptyp)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
327 (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
328 ;; Jump to the end, and set the process mark.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
329 (goto-char (point-max))
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
330 (set-marker (process-mark proc) (point))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
331 ;; Feed it the startfile.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
332 (cond (startfile
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
333 ;;This is guaranteed to wait long enough
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
334 ;;but has bad results if the comint does not prompt at all
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
335 ;; (while (= size (buffer-size))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
336 ;; (sleep-for 1))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
337 ;;I hope 1 second is enough!
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
338 (sleep-for 1)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
339 (goto-char (point-max))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
340 (insert-file-contents startfile)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
341 (setq startfile (buffer-substring (point) (point-max)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
342 (delete-region (point) (point-max))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
343 (comint-send-string proc startfile)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
344 (run-hooks 'comint-exec-hook)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
345 buffer)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
346
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
347 ;;; This auxiliary function cranks up the process for comint-exec in
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
348 ;;; the appropriate environment.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
349
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
350 (defun comint-exec-1 (name buffer command switches)
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
351 (let ((process-environment
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
352 (comint-update-env process-environment
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
353 (list (format "TERMCAP=emacs:co#%d:tc=unknown"
778
cd00bdacc17b *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 768
diff changeset
354 (frame-width))
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
355 "TERM=emacs"
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
356 "EMACS=t"))))
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
357 (apply 'start-process name buffer command switches)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
358
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
359
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
360
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
361 ;; This is just (append new old-env) that compresses out shadowed entries.
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
362 ;; It's also pretty ugly, mostly due to lisp's horrible iteration structures.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
363 (defun comint-update-env (old-env new)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
364 (let ((ans (reverse new))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
365 (vars (mapcar (function (lambda (vv)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
366 (and (string-match "^[^=]*=" vv)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
367 (substring vv 0 (match-end 0)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
368 new)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
369 (while old-env
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
370 (let* ((vv (car old-env)) ; vv is var=value
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
371 (var (and (string-match "^[^=]*=" vv)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
372 (substring vv 0 (match-end 0)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
373 (setq old-env (cdr old-env))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
374 (cond ((not (and var (comint-mem var vars)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
375 (if var (setq var (cons var vars)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
376 (setq ans (cons vv ans))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
377 (nreverse ans)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
378
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
379 ;;; This should be in emacs, but it isn't.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
380 (defun comint-mem (item list &optional elt=)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
381 "Test to see if ITEM is equal to an item in LIST.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
382 Option comparison function ELT= defaults to equal."
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
383 (let ((elt= (or elt= (function equal)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
384 (done nil))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
385 (while (and list (not done))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
386 (if (funcall elt= item (car list))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
387 (setq done list)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
388 (setq list (cdr list))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
389 done))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
390
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
391
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
392 ;;; Input history retrieval commands
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
393 ;;; M-p -- previous input M-n -- next input
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
394 ;;; M-C-r -- previous input matching
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
395 ;;; ===========================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
396
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
397 (defun comint-previous-input (arg)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
398 "Cycle backwards through input history."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
399 (interactive "*p")
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
400 (let ((len (ring-length comint-input-ring)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
401 (cond ((<= len 0)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
402 (message "Empty input ring")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
403 (ding))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
404 ((not (comint-after-pmark-p))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
405 (message "Not after process mark")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
406 (ding))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
407 (t
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
408 (delete-region (point)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
409 (process-mark (get-buffer-process (current-buffer))))
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
410 ;; Initialize the index on the first use of this command
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
411 ;; so that the first M-p gets index 0, and the first M-n gets
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
412 ;; index -1.
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
413 (if (null comint-input-ring-index)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
414 (setq comint-input-ring-index
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
415 (if (> arg 0) -1
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
416 (if (< arg 0) 1 0))))
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
417 (setq comint-input-ring-index
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
418 (comint-mod (+ comint-input-ring-index arg) len))
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
419 (message "%d" (1+ comint-input-ring-index))
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
420 (insert (ring-ref comint-input-ring comint-input-ring-index))))))
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
421
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
422 (defun comint-mod (n m)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
423 "Returns N mod M. M is positive.
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
424 Answer is guaranteed to be non-negative, and less than m."
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
425 (let ((n (% n m)))
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
426 (if (>= n 0) n
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
427 (+ n
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
428 (if (>= m 0) m (- m)))))) ; (abs m)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
429
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
430 (defun comint-next-input (arg)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
431 "Cycle forwards through input history."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
432 (interactive "*p")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
433 (comint-previous-input (- arg)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
434
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
435 (defun comint-previous-input-matching (str)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
436 "Searches backwards through input history for substring match."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
437 (interactive (let* ((last-command last-command) ; preserve around r-f-m
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
438 (s (read-from-minibuffer
864
fe5f6b7c9727 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 861
diff changeset
439 (format "Command substring (default %s): "
fe5f6b7c9727 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 861
diff changeset
440 comint-last-input-match))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
441 (list (if (string= s "") comint-last-input-match s))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
442 ; (interactive "sCommand substring: ")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
443 (setq comint-last-input-match str) ; update default
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
444 (if (null comint-input-ring-index)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
445 (setq comint-input-ring-index -1))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
446 (let ((str (regexp-quote str))
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
447 (len (ring-length comint-input-ring))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
448 (n (+ comint-input-ring-index 1)))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
449 (while (and (< n len) (not (string-match str (ring-ref comint-input-ring n))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
450 (setq n (+ n 1)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
451 (cond ((< n len)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
452 (comint-previous-input (- n comint-input-ring-index)))
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
453 (t (error "Not found")))))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
454
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
455
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
456 ;;; These next three commands are alternatives to the input history commands
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
457 ;;; -- comint-next-input, comint-previous-input and
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
458 ;;; comint-previous-input-matching. They search through the process buffer
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
459 ;;; text looking for occurrences of the prompt. Bound to M-P, M-N, and C-c R
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
460 ;;; (uppercase P, N, and R) for now. Try'em out. Go with what you like...
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
461
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
462 ;;; comint-msearch-input-matching prompts for a string, not a regexp.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
463 ;;; This could be considered to be the wrong thing. I decided to keep it
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
464 ;;; simple, and not make the user worry about regexps. This, of course,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
465 ;;; limits functionality.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
466
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
467 ;;; These commands were deemed non-winning and have been commented out.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
468 ;;; Feel free to re-enable them if you like. -Olin 3/91
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
469
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
470 ;(defun comint-psearch-input ()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
471 ; "Search forwards for next occurrence of prompt and skip to end of line.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
472 ;\(prompt is anything matching regexp comint-prompt-regexp)"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
473 ; (interactive)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
474 ; (if (re-search-forward comint-prompt-regexp (point-max) t)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
475 ; (end-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
476 ; (error "No occurrence of prompt found")))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
477 ;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
478 ;(defun comint-msearch-input ()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
479 ; "Search backwards for previous occurrence of prompt and skip to end of line.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
480 ;Search starts from beginning of current line."
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
481 ; (interactive)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
482 ; (let ((p (save-excursion
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
483 ; (beginning-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
484 ; (cond ((re-search-backward comint-prompt-regexp (point-min) t)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
485 ; (end-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
486 ; (point))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
487 ; (t nil)))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
488 ; (if p (goto-char p)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
489 ; (error "No occurrence of prompt found"))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
490 ;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
491 ;(defun comint-msearch-input-matching (str)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
492 ; "Search backwards for occurrence of prompt followed by STRING.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
493 ;STRING is prompted for, and is NOT a regular expression."
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
494 ; (interactive (let ((s (read-from-minibuffer
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
495 ; (format "Command (default %s): "
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
496 ; comint-last-input-match))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
497 ; (list (if (string= s "") comint-last-input-match s))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
498 ;; (interactive "sCommand: ")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
499 ; (setq comint-last-input-match str) ; update default
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
500 ; (let* ((r (concat comint-prompt-regexp (regexp-quote str)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
501 ; (p (save-excursion
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
502 ; (beginning-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
503 ; (cond ((re-search-backward r (point-min) t)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
504 ; (end-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
505 ; (point))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
506 ; (t nil)))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
507 ; (if p (goto-char p)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
508 ; (error "No match"))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
509
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
510 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
511 ;;; Similar input -- contributed by ccm and highly winning.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
512 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
513 ;;; Reenter input, removing back to the last insert point if it exists.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
514 ;;;
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
515 (defvar comint-last-similar-string ""
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
516 "The string last used in a similar string search.")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
517 (defun comint-previous-similar-input (arg)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
518 "Fetch the previous (older) input that matches the string typed so far.
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
519 Successive repetitions find successively older matching inputs.
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
520 A prefix argument serves as a repeat count; a negative argument
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
521 fetches following (more recent) inputs."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
522 (interactive "p")
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
523 (if (not (comint-after-pmark-p))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
524 (error "Not after process mark"))
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
525 (if (null comint-input-ring-index)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
526 (setq comint-input-ring-index
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
527 (if (> arg 0) -1
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
528 (if (< arg 0) 1 0))))
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
529 (if (not (or (eq last-command 'comint-previous-similar-input)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
530 (eq last-command 'comint-next-similar-input)))
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
531 (setq comint-last-similar-string
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
532 (buffer-substring
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
533 (process-mark (get-buffer-process (current-buffer)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
534 (point))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
535 (let* ((size (length comint-last-similar-string))
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
536 (len (ring-length comint-input-ring))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
537 (n (+ comint-input-ring-index arg))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
538 entry)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
539 (while (and (< n len)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
540 (or (< (length (setq entry (ring-ref comint-input-ring n))) size)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
541 (not (equal comint-last-similar-string
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
542 (substring entry 0 size)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
543 (setq n (+ n arg)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
544 (cond ((< n len)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
545 (setq comint-input-ring-index n)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
546 (if (or (eq last-command 'comint-previous-similar-input)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
547 (eq last-command 'comint-next-similar-input))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
548 (delete-region (mark) (point)) ; repeat
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
549 (push-mark (point))) ; 1st time
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
550 (insert (substring entry size)))
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
551 (t (error "Not found")))
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
552 (message "%d" (1+ comint-input-ring-index))))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
553
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
554 (defun comint-next-similar-input (arg)
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
555 "Fetch the next (newer) input that matches the string typed so far.
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
556 Successive repetitions find successively newer matching inputs.
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
557 A prefix argument serves as a repeat count; a negative argument
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
558 fetches previous (older) inputs."
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
559 (interactive "p")
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
560 (comint-previous-similar-input (- arg)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
561
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
562 (defun comint-send-input ()
1356
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
563 "Send input to process.
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
564 After the process output mark, sends all text from the process mark to
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
565 point as input to the process. Before the process output mark, calls value
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
566 of variable comint-get-old-input to retrieve old input, copies it to the
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
567 process mark, and sends it. A terminal newline is also inserted into the
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
568 buffer and sent to the process. In either case, value of variable
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
569 comint-input-sentinel is called on the input before sending it. The input
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
570 is entered into the input history ring, if the value of variable
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
571 comint-input-filter returns non-nil when called on the input.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
572
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
573 If variable comint-eol-on-send is non-nil, then point is moved to the end of
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
574 line before sending the input.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
575
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
576 comint-get-old-input, comint-input-sentinel, and comint-input-filter are chosen
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
577 according to the command interpreter running in the buffer. E.g.,
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
578 If the interpreter is the csh,
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
579 comint-get-old-input is the default: take the current line, discard any
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
580 initial string matching regexp comint-prompt-regexp.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
581 comint-input-sentinel monitors input for \"cd\", \"pushd\", and \"popd\"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
582 commands. When it sees one, it cd's the buffer.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
583 comint-input-filter is the default: returns T if the input isn't all white
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
584 space.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
585
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
586 If the comint is Lucid Common Lisp,
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
587 comint-get-old-input snarfs the sexp ending at point.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
588 comint-input-sentinel does nothing.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
589 comint-input-filter returns NIL if the input matches input-filter-regexp,
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
590 which matches (1) all whitespace (2) :a, :c, etc.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
591
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
592 Similarly for Soar, Scheme, etc."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
593 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
594 ;; Note that the input string does not include its terminal newline.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
595 (let ((proc (get-buffer-process (current-buffer))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
596 (if (not proc) (error "Current buffer has no process")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
597 (let* ((pmark (process-mark proc))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
598 (pmark-val (marker-position pmark))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
599 (input (if (>= (point) pmark-val)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
600 (progn (if comint-eol-on-send (end-of-line))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
601 (buffer-substring pmark (point)))
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
602 (let ((copy (funcall comint-get-old-input)))
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
603 (goto-char pmark)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
604 (insert copy)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
605 copy))))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
606 (insert ?\n)
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
607 (if (funcall comint-input-filter input)
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
608 (ring-insert comint-input-ring input))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
609 (funcall comint-input-sentinel input)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
610 (funcall comint-input-sender proc input)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
611 (setq comint-input-ring-index nil)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
612 (set-marker comint-last-input-start pmark)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
613 (set-marker comint-last-input-end (point))
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
614 (set-marker (process-mark proc) (point))))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
615
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
616 (defun comint-get-old-input-default ()
1356
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
617 "Default for comint-get-old-input.
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
618 Take the current line, and discard any initial text matching
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
619 comint-prompt-regexp."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
620 (save-excursion
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
621 (beginning-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
622 (comint-skip-prompt)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
623 (let ((beg (point)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
624 (end-of-line)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
625 (buffer-substring beg (point)))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
626
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
627 (defun comint-skip-prompt ()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
628 "Skip past the text matching regexp comint-prompt-regexp.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
629 If this takes us past the end of the current line, don't skip at all."
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
630 (let ((eol (save-excursion (end-of-line) (point))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
631 (if (and (looking-at comint-prompt-regexp)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
632 (<= (match-end 0) eol))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
633 (goto-char (match-end 0)))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
634
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
635
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
636 (defun comint-after-pmark-p ()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
637 "Is point after the process output marker?"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
638 ;; Since output could come into the buffer after we looked at the point
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
639 ;; but before we looked at the process marker's value, we explicitly
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
640 ;; serialise. This is just because I don't know whether or not emacs
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
641 ;; services input during execution of lisp commands.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
642 (let ((proc-pos (marker-position
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
643 (process-mark (get-buffer-process (current-buffer))))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
644 (<= proc-pos (point))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
645
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
646 (defun comint-simple-send (proc string)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
647 "Default function for sending to PROC input STRING.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
648 This just sends STRING plus a newline. To override this,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
649 set the hook COMINT-INPUT-SENDER."
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
650 (comint-send-string proc string)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
651 (comint-send-string proc "\n"))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
652
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
653 (defun comint-bol (arg)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
654 "Goes to the beginning of line, then skips past the prompt, if any.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
655 If a prefix argument is given (\\[universal-argument]), then no prompt skip
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
656 -- go straight to column 0.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
657
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
658 The prompt skip is done by skipping text matching the regular expression
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
659 comint-prompt-regexp, a buffer local variable.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
660
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
661 If you don't like this command, reset c-a to beginning-of-line
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
662 in your hook, comint-mode-hook."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
663 (interactive "P")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
664 (beginning-of-line)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
665 (if (null arg) (comint-skip-prompt)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
666
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
667 ;;; These two functions are for entering text you don't want echoed or
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
668 ;;; saved -- typically passwords to ftp, telnet, or somesuch.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
669 ;;; Just enter m-x send-invisible and type in your line.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
670
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
671 (defun comint-read-noecho (prompt &optional stars)
2455
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
672 "Read a single line of text from user without echoing, and return it.
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
673 Prompt with argument PROMPT, a string. Optional argument STARS causes
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
674 input to be echoed with '*' characters on the prompt line. Input ends with
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
675 RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. C-g aborts (if
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
676 inhibit-quit is set because e.g. this function was called from a process
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
677 filter and C-g is pressed, this function will return `nil', rather than a
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
678 string).
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
679
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
680 Note that the keystrokes comprising the text can still be recovered
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
681 (temporarily) with \\[view-lossage]. This may be a security bug for some
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
682 applications."
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
683 (let ((ans "")
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
684 (c 0)
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
685 (echo-keystrokes 0)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
686 (cursor-in-echo-area t)
2455
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
687 (done nil))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
688 (while (not done)
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
689 (if stars
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
690 (message "%s%s" prompt (make-string (length ans) ?*))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
691 (message prompt))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
692 (setq c (read-char))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
693 (cond ((= c ?\C-g)
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
694 ;; This function may get called from a process filter, where
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
695 ;; inhibit-quit is set. In later versions of emacs read-char
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
696 ;; may clear quit-flag itself and return C-g. That would make
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
697 ;; it impossible to quit this loop in a simple way, so
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
698 ;; re-enable it here (for backward-compatibility the check for
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
699 ;; quit-flag below would still be necessary, so this is seems
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
700 ;; like the simplest way to do things).
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
701 (setq quit-flag t
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
702 done t))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
703 ((or (= c ?\r) (= c ?\n) (= c ?\e))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
704 (setq done t))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
705 ((= c ?\C-u)
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
706 (setq ans ""))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
707 ((and (/= c ?\b) (/= c ?\177))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
708 (setq ans (concat ans (char-to-string c))))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
709 ((> (length ans) 0)
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
710 (setq ans (substring ans 0 -1)))))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
711 (if quit-flag
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
712 ;; Emulate a true quit, except that we have to return a value.
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
713 (prog1
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
714 (setq quit-flag nil)
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
715 (message "Quit")
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
716 (beep t))
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
717 (message "")
27d28402ee59 new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents: 2307
diff changeset
718 ans)))
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
719
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
720 (defun send-invisible (str)
1356
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
721 "Read a string without echoing.
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
722 Then send it to the process running in the current buffer. A new-line
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
723 is additionally sent. String is not saved on comint input history list.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
724 Security bug: your string can still be temporarily recovered with
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
725 \\[view-lossage]."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
726 ; (interactive (list (comint-read-noecho "Enter non-echoed text")))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
727 (interactive "P") ; Defeat snooping via C-x esc
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
728 (let ((proc (get-buffer-process (current-buffer))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
729 (if (not proc) (error "Current buffer has no process")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
730 (comint-send-string proc
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
731 (if (stringp str) str
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
732 (comint-read-noecho "Non-echoed text: " t)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
733 (comint-send-string proc "\n"))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
734
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
735
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
736 ;;; Low-level process communication
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
737
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
738 (defvar comint-input-chunk-size 512
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
739 "*Long inputs send to comint processes are broken up into chunks of this size.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
740 If your process is choking on big inputs, try lowering the value.")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
741
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
742 (defun comint-send-string (proc str)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
743 "Send PROCESS the contents of STRING as input.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
744 This is equivalent to process-send-string, except that long input strings
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
745 are broken up into chunks of size comint-input-chunk-size. Processes
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
746 are given a chance to output between chunks. This can help prevent processes
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
747 from hanging when you send them long inputs on some OS's."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
748 (let* ((len (length str))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
749 (i (min len comint-input-chunk-size)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
750 (process-send-string proc (substring str 0 i))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
751 (while (< i len)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
752 (let ((next-i (+ i comint-input-chunk-size)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
753 (accept-process-output)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
754 (process-send-string proc (substring str i (min len next-i)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
755 (setq i next-i)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
756
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
757 (defun comint-send-region (proc start end)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
758 "Sends to PROC the region delimited by START and END.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
759 This is a replacement for process-send-region that tries to keep
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
760 your process from hanging on long inputs. See comint-send-string."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
761 (comint-send-string proc (buffer-substring start end)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
762
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
763
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
764 ;;; Random input hackage
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
765
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
766 (defun comint-kill-output ()
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
767 "Kill all output from interpreter since last input."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
768 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
769 (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
770 (kill-region comint-last-input-end pmark)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
771 (goto-char pmark)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
772 (insert "*** output flushed ***\n")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
773 (set-marker pmark (point))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
774
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
775 (defun comint-show-output ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
776 "Display start of this batch of interpreter output at top of window.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
777 Also put cursor there."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
778 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
779 (goto-char comint-last-input-end)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
780 (backward-char)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
781 (beginning-of-line)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
782 (set-window-start (selected-window) (point))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
783 (end-of-line))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
784
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
785 (defun comint-interrupt-subjob ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
786 "Interrupt the current subjob."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
787 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
788 (interrupt-process nil comint-ptyp))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
789
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
790 (defun comint-kill-subjob ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
791 "Send kill signal to the current subjob."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
792 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
793 (kill-process nil comint-ptyp))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
794
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
795 (defun comint-quit-subjob ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
796 "Send quit signal to the current subjob."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
797 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
798 (quit-process nil comint-ptyp))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
799
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
800 (defun comint-stop-subjob ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
801 "Stop the current subjob.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
802 WARNING: if there is no current subjob, you can end up suspending
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
803 the top-level process running in the buffer. If you accidentally do
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
804 this, use \\[comint-continue-subjob] to resume the process. (This
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
805 is not a problem with most shells, since they ignore this signal.)"
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
806 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
807 (stop-process nil comint-ptyp))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
808
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
809 (defun comint-continue-subjob ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
810 "Send CONT signal to process buffer's process group.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
811 Useful if you accidentally suspend the top-level process."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
812 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
813 (continue-process nil comint-ptyp))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
814
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
815 (defun comint-kill-input ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
816 "Kill all text from last stuff output by interpreter to point."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
817 (interactive)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
818 (let* ((pmark (process-mark (get-buffer-process (current-buffer))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
819 (p-pos (marker-position pmark)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
820 (if (> (point) p-pos)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
821 (kill-region pmark (point)))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
822
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
823 (defun comint-delchar-or-maybe-eof (arg)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
824 "Delete ARG characters forward, or send an EOF to process if at end of buffer."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
825 (interactive "p")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
826 (if (eobp)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
827 (process-send-eof)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
828 (delete-char arg)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
829
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
830
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
831
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
832
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
833 ;;; Support for source-file processing commands.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
834 ;;;============================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
835 ;;; Many command-interpreters (e.g., Lisp, Scheme, Soar) have
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
836 ;;; commands that process files of source text (e.g. loading or compiling
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
837 ;;; files). So the corresponding process-in-a-buffer modes have commands
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
838 ;;; for doing this (e.g., lisp-load-file). The functions below are useful
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
839 ;;; for defining these commands.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
840 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
841 ;;; Alas, these guys don't do exactly the right thing for Lisp, Scheme
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
842 ;;; and Soar, in that they don't know anything about file extensions.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
843 ;;; So the compile/load interface gets the wrong default occasionally.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
844 ;;; The load-file/compile-file default mechanism could be smarter -- it
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
845 ;;; doesn't know about the relationship between filename extensions and
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
846 ;;; whether the file is source or executable. If you compile foo.lisp
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
847 ;;; with compile-file, then the next load-file should use foo.bin for
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
848 ;;; the default, not foo.lisp. This is tricky to do right, particularly
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
849 ;;; because the extension for executable files varies so much (.o, .bin,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
850 ;;; .lbin, .mo, .vo, .ao, ...).
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
851
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
852
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
853 ;;; COMINT-SOURCE-DEFAULT -- determines defaults for source-file processing
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
854 ;;; commands.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
855 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
856 ;;; COMINT-CHECK-SOURCE -- if FNAME is in a modified buffer, asks you if you
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
857 ;;; want to save the buffer before issuing any process requests to the command
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
858 ;;; interpreter.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
859 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
860 ;;; COMINT-GET-SOURCE -- used by the source-file processing commands to prompt
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
861 ;;; for the file to process.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
862
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
863 ;;; (COMINT-SOURCE-DEFAULT previous-dir/file source-modes)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
864 ;;;============================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
865 ;;; This function computes the defaults for the load-file and compile-file
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
866 ;;; commands for tea, soar, cmulisp, and cmuscheme modes.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
867 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
868 ;;; - PREVIOUS-DIR/FILE is a pair (directory . filename) from the last
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
869 ;;; source-file processing command. NIL if there hasn't been one yet.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
870 ;;; - SOURCE-MODES is a list used to determine what buffers contain source
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
871 ;;; files: if the major mode of the buffer is in SOURCE-MODES, it's source.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
872 ;;; Typically, (lisp-mode) or (scheme-mode).
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
873 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
874 ;;; If the command is given while the cursor is inside a string, *and*
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
875 ;;; the string is an existing filename, *and* the filename is not a directory,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
876 ;;; then the string is taken as default. This allows you to just position
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
877 ;;; your cursor over a string that's a filename and have it taken as default.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
878 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
879 ;;; If the command is given in a file buffer whose major mode is in
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
880 ;;; SOURCE-MODES, then the the filename is the default file, and the
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
881 ;;; file's directory is the default directory.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
882 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
883 ;;; If the buffer isn't a source file buffer (e.g., it's the process buffer),
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
884 ;;; then the default directory & file are what was used in the last source-file
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
885 ;;; processing command (i.e., PREVIOUS-DIR/FILE). If this is the first time
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
886 ;;; the command has been run (PREVIOUS-DIR/FILE is nil), the default directory
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
887 ;;; is the cwd, with no default file. (\"no default file\" = nil)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
888 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
889 ;;; SOURCE-REGEXP is typically going to be something like (tea-mode)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
890 ;;; for T programs, (lisp-mode) for Lisp programs, (soar-mode lisp-mode)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
891 ;;; for Soar programs, etc.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
892 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
893 ;;; The function returns a pair: (default-directory . default-file).
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
894
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
895 (defun comint-source-default (previous-dir/file source-modes)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
896 (cond ((and buffer-file-name (memq major-mode source-modes))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
897 (cons (file-name-directory buffer-file-name)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
898 (file-name-nondirectory buffer-file-name)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
899 (previous-dir/file)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
900 (t
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
901 (cons default-directory nil))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
902
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
903
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
904 ;;; (COMINT-CHECK-SOURCE fname)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
905 ;;;============================================================================
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
906 ;;; Prior to loading or compiling (or otherwise processing) a file (in the CMU
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
907 ;;; process-in-a-buffer modes), this function can be called on the filename.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
908 ;;; If the file is loaded into a buffer, and the buffer is modified, the user
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
909 ;;; is queried to see if he wants to save the buffer before proceeding with
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
910 ;;; the load or compile.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
911
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
912 (defun comint-check-source (fname)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
913 (let ((buff (get-file-buffer fname)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
914 (if (and buff
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
915 (buffer-modified-p buff)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
916 (y-or-n-p (format "Save buffer %s first? "
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
917 (buffer-name buff))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
918 ;; save BUFF.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
919 (let ((old-buffer (current-buffer)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
920 (set-buffer buff)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
921 (save-buffer)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
922 (set-buffer old-buffer)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
923
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
924
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
925 ;;; (COMINT-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
926 ;;;============================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
927 ;;; COMINT-GET-SOURCE is used to prompt for filenames in command-interpreter
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
928 ;;; commands that process source files (like loading or compiling a file).
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
929 ;;; It prompts for the filename, provides a default, if there is one,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
930 ;;; and returns the result filename.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
931 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
932 ;;; See COMINT-SOURCE-DEFAULT for more on determining defaults.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
933 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
934 ;;; PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
935 ;;; from the last source processing command. SOURCE-MODES is a list of major
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
936 ;;; modes used to determine what file buffers contain source files. (These
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
937 ;;; two arguments are used for determining defaults). If MUSTMATCH-P is true,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
938 ;;; then the filename reader will only accept a file that exists.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
939 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
940 ;;; A typical use:
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
941 ;;; (interactive (comint-get-source "Compile file: " prev-lisp-dir/file
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
942 ;;; '(lisp-mode) t))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
943
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
944 ;;; This is pretty stupid about strings. It decides we're in a string
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
945 ;;; if there's a quote on both sides of point on the current line.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
946 (defun comint-extract-string ()
1373
7fc9bbcae71b Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1356
diff changeset
947 "Returns string around POINT that starts the current line or nil."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
948 (save-excursion
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
949 (let* ((point (point))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
950 (bol (progn (beginning-of-line) (point)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
951 (eol (progn (end-of-line) (point)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
952 (start (progn (goto-char point)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
953 (and (search-backward "\"" bol t)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
954 (1+ (point)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
955 (end (progn (goto-char point)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
956 (and (search-forward "\"" eol t)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
957 (1- (point))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
958 (and start end
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
959 (buffer-substring start end)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
960
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
961 (defun comint-get-source (prompt prev-dir/file source-modes mustmatch-p)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
962 (let* ((def (comint-source-default prev-dir/file source-modes))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
963 (stringfile (comint-extract-string))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
964 (sfile-p (and stringfile
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
965 (condition-case ()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
966 (file-exists-p stringfile)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
967 (error nil))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
968 (not (file-directory-p stringfile))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
969 (defdir (if sfile-p (file-name-directory stringfile)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
970 (car def)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
971 (deffile (if sfile-p (file-name-nondirectory stringfile)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
972 (cdr def)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
973 (ans (read-file-name (if deffile (format "%s(default %s) "
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
974 prompt deffile)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
975 prompt)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
976 defdir
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
977 (concat defdir deffile)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
978 mustmatch-p)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
979 (list (expand-file-name (substitute-in-file-name ans)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
980
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
981 ;;; I am somewhat divided on this string-default feature. It seems
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
982 ;;; to violate the principle-of-least-astonishment, in that it makes
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
983 ;;; the default harder to predict, so you actually have to look and see
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
984 ;;; what the default really is before choosing it. This can trip you up.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
985 ;;; On the other hand, it can be useful, I guess. I would appreciate feedback
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
986 ;;; on this.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
987 ;;; -Olin
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
988
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
989
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
990 ;;; Simple process query facility.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
991 ;;; ===========================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
992 ;;; This function is for commands that want to send a query to the process
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
993 ;;; and show the response to the user. For example, a command to get the
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
994 ;;; arglist for a Common Lisp function might send a "(arglist 'foo)" query
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
995 ;;; to an inferior Common Lisp process.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
996 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
997 ;;; This simple facility just sends strings to the inferior process and pops
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
998 ;;; up a window for the process buffer so you can see what the process
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
999 ;;; responds with. We don't do anything fancy like try to intercept what the
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1000 ;;; process responds with and put it in a pop-up window or on the message
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1001 ;;; line. We just display the buffer. Low tech. Simple. Works good.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1002
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1003 ;;; Send to the inferior process PROC the string STR. Pop-up but do not select
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1004 ;;; a window for the inferior process so that its response can be seen.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1005 (defun comint-proc-query (proc str)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1006 (let* ((proc-buf (process-buffer proc))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1007 (proc-mark (process-mark proc)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1008 (display-buffer proc-buf)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1009 (set-buffer proc-buf) ; but it's not the selected *window*
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1010 (let ((proc-win (get-buffer-window proc-buf))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1011 (proc-pt (marker-position proc-mark)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1012 (comint-send-string proc str) ; send the query
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1013 (accept-process-output proc) ; wait for some output
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1014 ;; Try to position the proc window so you can see the answer.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1015 ;; This is bogus code. If you delete the (sit-for 0), it breaks.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1016 ;; I don't know why. Wizards invited to improve it.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1017 (if (not (pos-visible-in-window-p proc-pt proc-win))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1018 (let ((opoint (window-point proc-win)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1019 (set-window-point proc-win proc-mark) (sit-for 0)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1020 (if (not (pos-visible-in-window-p opoint proc-win))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1021 (push-mark opoint)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1022 (set-window-point proc-win opoint)))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1023
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1024
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1025 ;;; Filename completion in a buffer
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1026 ;;; ===========================================================================
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1027 ;;; Useful completion functions, courtesy of the Ergo group.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1028
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1029 ;;; Three commands:
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1030 ;;; comint-dynamic-complete Complete filename at point.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1031 ;;; comint-dynamic-list-completions List completions in help buffer.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1032 ;;; comint-replace-by-expanded-filename Expand and complete filename at point;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1033 ;;; replace with expanded/completed name.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1034
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1035 ;;; These are not installed in the comint-mode keymap. But they are
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1036 ;;; available for people who want them. Shell-mode installs them:
2518
10509afe2588 Clean up cmu* uses in header comments.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2455
diff changeset
1037 ;;; (define-key shell-mode-map "\t" 'comint-dynamic-complete)
10509afe2588 Clean up cmu* uses in header comments.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2455
diff changeset
1038 ;;; (define-key shell-mode-map "\M-?" 'comint-dynamic-list-completions)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1039 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1040 ;;; Commands like this are fine things to put in load hooks if you
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1041 ;;; want them present in specific modes.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1042
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1043
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1044 (defun comint-match-partial-pathname ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1045 "Returns the filename at point or causes an error."
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1046 (save-excursion
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1047 (if (re-search-backward "[^~/A-Za-z0-9---_.$#,=]" nil 'move)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1048 (forward-char 1))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1049 ;; Anchor the search forwards.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1050 (if (not (looking-at "[~/A-Za-z0-9---_.$#,=]")) (error ""))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1051 (re-search-forward "[~/A-Za-z0-9---_.$#,=]+")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1052 (substitute-in-file-name
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1053 (buffer-substring (match-beginning 0) (match-end 0)))))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1054
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1055
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1056 (defun comint-replace-by-expanded-filename ()
1356
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
1057 "Expand the filename at point.
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
1058 Replace the filename with an expanded, canonicalised, and completed
dcf780f7ae1b Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1131
diff changeset
1059 replacement.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1060 \"Expanded\" means environment variables (e.g., $HOME) and ~'s are
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1061 replaced with the corresponding directories. \"Canonicalised\" means ..
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1062 and \. are removed, and the filename is made absolute instead of relative.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1063 See functions expand-file-name and substitute-in-file-name. See also
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1064 comint-dynamic-complete."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1065 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1066 (let* ((pathname (comint-match-partial-pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1067 (pathdir (file-name-directory pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1068 (pathnondir (file-name-nondirectory pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1069 (completion (file-name-completion pathnondir
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1070 (or pathdir default-directory))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1071 (cond ((null completion)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1072 (message "No completions of %s" pathname)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1073 (ding))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1074 ((eql completion t)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1075 (message "Unique completion"))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1076 (t ; this means a string was returned.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1077 (delete-region (match-beginning 0) (match-end 0))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1078 (insert (expand-file-name (concat pathdir completion)))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1079
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1080
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1081 (defun comint-dynamic-complete ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1082 "Dynamically complete the filename at point.
1373
7fc9bbcae71b Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 1356
diff changeset
1083 This function is similar to `comint-replace-by-expanded-filename', except
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1084 that it won't change parts of the filename already entered in the buffer;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1085 it just adds completion characters to the end of the filename."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1086 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1087 (let* ((pathname (comint-match-partial-pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1088 (pathdir (file-name-directory pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1089 (pathnondir (file-name-nondirectory pathname))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1090 (completion (file-name-completion pathnondir
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1091 (or pathdir default-directory))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1092 (cond ((null completion)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1093 (message "No completions of %s" pathname)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1094 (ding))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1095 ((eql completion t)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1096 (message "Unique completion"))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1097 (t ; this means a string was returned.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1098 (goto-char (match-end 0))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1099 (insert (substring completion (length pathnondir)))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1100
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1101 (defun comint-dynamic-list-completions ()
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1102 "List in help buffer all possible completions of the filename at point."
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1103 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1104 (let* ((pathname (comint-match-partial-pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1105 (pathdir (file-name-directory pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1106 (pathnondir (file-name-nondirectory pathname))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1107 (completions
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1108 (file-name-all-completions pathnondir
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1109 (or pathdir default-directory))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1110 (cond ((null completions)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1111 (message "No completions of %s" pathname)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1112 (ding))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1113 (t
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1114 (let ((conf (current-window-configuration)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1115 (with-output-to-temp-buffer "*Help*"
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1116 (display-completion-list completions))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1117 (sit-for 0)
909
4c6cdb66c74c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 870
diff changeset
1118 (message "Hit space to flush")
2022
9a765951a9b9 (comint-dynamic-list-completions): Handle any event when flushing the display.
Richard M. Stallman <rms@gnu.org>
parents: 1839
diff changeset
1119 (let ((ch (read-event)))
2025
3f02dc3e10a8 Fix bug in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 2022
diff changeset
1120 (if (eq ch ?\ )
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1121 (set-window-configuration conf)
2022
9a765951a9b9 (comint-dynamic-list-completions): Handle any event when flushing the display.
Richard M. Stallman <rms@gnu.org>
parents: 1839
diff changeset
1122 (setq unread-command-events (list ch)))))))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1123
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1124 ;;; Converting process modes to use comint mode
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1125 ;;; ===========================================================================
768
4abf65b235d9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 705
diff changeset
1126 ;;; The code in the Emacs 19 distribution has all been modified to use comint
4abf65b235d9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 705
diff changeset
1127 ;;; where needed. However, there are `third-party' packages out there that
4abf65b235d9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 705
diff changeset
1128 ;;; still use the old shell mode. Here's a guide to conversion.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1129 ;;;
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1130 ;;; Renaming variables
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1131 ;;; Most of the work is renaming variables and functions. These are the common
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1132 ;;; ones:
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1133 ;;; Local variables:
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1134 ;;; last-input-start comint-last-input-start
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1135 ;;; last-input-end comint-last-input-end
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1136 ;;; shell-prompt-pattern comint-prompt-regexp
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1137 ;;; shell-set-directory-error-hook <no equivalent>
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1138 ;;; Miscellaneous:
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1139 ;;; shell-set-directory <unnecessary>
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1140 ;;; shell-mode-map comint-mode-map
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1141 ;;; Commands:
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1142 ;;; shell-send-input comint-send-input
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1143 ;;; shell-send-eof comint-delchar-or-maybe-eof
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1144 ;;; kill-shell-input comint-kill-input
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1145 ;;; interrupt-shell-subjob comint-interrupt-subjob
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1146 ;;; stop-shell-subjob comint-stop-subjob
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1147 ;;; quit-shell-subjob comint-quit-subjob
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1148 ;;; kill-shell-subjob comint-kill-subjob
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1149 ;;; kill-output-from-shell comint-kill-output
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1150 ;;; show-output-from-shell comint-show-output
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1151 ;;; copy-last-shell-input Use comint-previous-input/comint-next-input
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1152 ;;;
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1153 ;;; SHELL-SET-DIRECTORY is gone, its functionality taken over by
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1154 ;;; SHELL-DIRECTORY-TRACKER, the shell mode's comint-input-sentinel.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1155 ;;; Comint mode does not provide functionality equivalent to
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1156 ;;; shell-set-directory-error-hook; it is gone.
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1157 ;;;
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1158 ;;; comint-last-input-start is provided for modes which want to munge
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1159 ;;; the buffer after input is sent, perhaps because the inferior
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1160 ;;; insists on echoing the input. The LAST-INPUT-START variable in
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1161 ;;; the old shell package was used to implement a history mechanism,
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1162 ;;; but you should think twice before using comint-last-input-start
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1163 ;;; for this; the input history ring often does the job better.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1164 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1165 ;;; If you are implementing some process-in-a-buffer mode, called foo-mode, do
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1166 ;;; *not* create the comint-mode local variables in your foo-mode function.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1167 ;;; This is not modular. Instead, call comint-mode, and let *it* create the
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1168 ;;; necessary comint-specific local variables. Then create the
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1169 ;;; foo-mode-specific local variables in foo-mode. Set the buffer's keymap to
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1170 ;;; be foo-mode-map, and its mode to be foo-mode. Set the comint-mode hooks
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1171 ;;; (comint-prompt-regexp, comint-input-filter, comint-input-sentinel,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1172 ;;; comint-get-old-input) that need to be different from the defaults. Call
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1173 ;;; foo-mode-hook, and you're done. Don't run the comint-mode hook yourself;
2518
10509afe2588 Clean up cmu* uses in header comments.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2455
diff changeset
1174 ;;; comint-mode will take care of it. The following example, from shell.el,
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1175 ;;; is typical:
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1176 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1177 ;;; (defun shell-mode ()
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1178 ;;; (interactive)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1179 ;;; (comint-mode)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1180 ;;; (setq comint-prompt-regexp shell-prompt-pattern)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1181 ;;; (setq major-mode 'shell-mode)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1182 ;;; (setq mode-name "Shell")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1183 ;;; (cond ((not shell-mode-map)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1184 ;;; (setq shell-mode-map (full-copy-sparse-keymap comint-mode-map))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1185 ;;; (define-key shell-mode-map "\M-\t" 'comint-dynamic-complete)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1186 ;;; (define-key shell-mode-map "\M-?"
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1187 ;;; 'comint-dynamic-list-completions)))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1188 ;;; (use-local-map shell-mode-map)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1189 ;;; (make-local-variable 'shell-directory-stack)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1190 ;;; (setq shell-directory-stack nil)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1191 ;;; (setq comint-input-sentinel 'shell-directory-tracker)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1192 ;;; (run-hooks 'shell-mode-hook))
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1193 ;;;
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1194 ;;;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1195 ;;; Note that make-comint is different from make-shell in that it
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1196 ;;; doesn't have a default program argument. If you give make-shell
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1197 ;;; a program name of NIL, it cleverly chooses one of explicit-shell-name,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1198 ;;; $ESHELL, $SHELL, or /bin/sh. If you give make-comint a program argument
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
1199 ;;; of NIL, it barfs. Adjust your code accordingly...
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1200 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1201
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1202 ;;; Do the user's customisation...
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1203
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1204 (defvar comint-load-hook nil
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1205 "This hook is run when comint is loaded in.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1206 This is a good place to put keybindings.")
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1207
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1208 (run-hooks 'comint-load-hook)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1209
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1210 ;;; Change log:
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1211 ;;; 9/12/89
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1212 ;;; - Souped up the filename expansion procedures.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1213 ;;; Doc strings are much clearer and more detailed.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1214 ;;; Fixed a bug where doing a filename completion when the point
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1215 ;;; was in the middle of the filename instead of at the end would lose.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1216 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1217 ;;; 2/17/90
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1218 ;;; - Souped up the command history stuff so that text inserted
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1219 ;;; by comint-previous-input-matching is removed by following
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1220 ;;; command history recalls. comint-next/previous-input-matching
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1221 ;;; is now much more smoothly integrated w/the command history stuff.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1222 ;;; - Added comint-eol-on-send flag and comint-input-sender hook.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1223 ;;; Comint-input-sender based on code contributed by Jeff Peck
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1224 ;;; (peck@sun.com).
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1225 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1226 ;;; 3/13/90 ccm@cmu.cs.edu
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1227 ;;; - Added comint-previous-similar-input for looking up similar inputs.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1228 ;;; - Added comint-send-and-get-output to allow snarfing input from
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1229 ;;; buffer.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1230 ;;; - Added the ability to pick up a source file by positioning over
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1231 ;;; a string in comint-get-source.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1232 ;;; - Added add-hook to make it a little easier for the user to use
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1233 ;;; multiple hooks.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1234 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1235 ;;; 5/22/90 shivers
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1236 ;;; - Moved Chris' multiplexed ipc stuff to comint-ipc.el.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1237 ;;; - Altered Chris' comint-get-source string feature. The string
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1238 ;;; is only offered as a default if it names an existing file.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1239 ;;; - Changed comint-exec to directly crank up the process, instead
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1240 ;;; of calling the env program. This made background.el happy.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1241 ;;; - Added new buffer-local var comint-ptyp. The problem is that
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1242 ;;; the signalling functions don't work as advertised. If you are
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1243 ;;; communicating via pipes, the CURRENT-GROUP arg is supposed to
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1244 ;;; be ignored, but, unfortunately it seems to be the case that you
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1245 ;;; must pass a NIL for this arg in the pipe case. COMINT-PTYP
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1246 ;;; is a flag that tells whether the process is communicating
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1247 ;;; via pipes or a pty. The comint signalling functions use it
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1248 ;;; to determine the necessary CURRENT-GROUP arg value. The bug
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1249 ;;; has been reported to the Gnu folks.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1250 ;;; - comint-dynamic-complete flushes the help window if you hit space
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1251 ;;; after you execute it.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1252 ;;; - Added functions comint-send-string, comint-send-region and var
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1253 ;;; comint-input-chunk-size. comint-send-string tries to prevent processes
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1254 ;;; from hanging when you send them long strings by breaking them into
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1255 ;;; chunks and allowing process output between chunks. I got the idea from
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1256 ;;; Eero Simoncelli's Common Lisp package. Note that using
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1257 ;;; comint-send-string means that the process buffer's contents can change
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1258 ;;; during a call! If you depend on process output only happening between
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1259 ;;; toplevel commands, this could be a problem. In such a case, use
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1260 ;;; process-send-string instead. If this is a problem for people, I'd like
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1261 ;;; to hear about it.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1262 ;;; - Added comint-proc-query as a simple mechanism for commands that
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1263 ;;; want to query an inferior process and display its response. For a
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1264 ;;; typical use, see lisp-show-arglist in cmulisp.el.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1265 ;;; - Added constant comint-version, which is now "2.01".
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1266 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1267 ;;; 6/14/90 shivers
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1268 ;;; - Had comint-update-env defined twice. Removed extra copy. Also
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1269 ;;; renamed mem to be comint-mem, for modularity. The duplication
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1270 ;;; was reported by Michael Meissner.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1271 ;;; 6/16/90 shivers
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1272 ;;; - Emacs has two different mechanisms for maintaining the process
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1273 ;;; environment, determined at compile time by the MAINTAIN-ENVIRONMENT
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1274 ;;; #define. One uses the process-environment global variable, and
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1275 ;;; one uses a getenv/setenv interface. comint-exec assumed the
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1276 ;;; process-environment interface; it has been generalised (with
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1277 ;;; comint-exec-1) to handle both cases. Pretty bogus. We could,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1278 ;;; of course, skip all this and just use the etc/env program to
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1279 ;;; handle the environment tweaking, but that obscures process
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1280 ;;; queries that other modules (like background.el) depend on. etc/env
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1281 ;;; is also fairly bogus. This bug, and some of the fix code was
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1282 ;;; reported by Dan Pierson.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1283 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1284 ;;; 9/5/90 shivers
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1285 ;;; - Changed make-variable-buffer-local's to make-local-variable's.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1286 ;;; This leaves non-comint-mode buffers alone. Stephane Payrard
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1287 ;;; reported the sloppy useage.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1288 ;;; - You can now go from comint-previous-similar-input to
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1289 ;;; comint-previous-input with no problem.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1290 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1291 ;;; 12/21/90 shivers
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1292 ;;; - Added a condition-case to comint-get-source. Bogus strings
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1293 ;;; beginning with ~ were making the file-exists-p barf.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1294 ;;; - Added "=" to the set of chars recognised by file completion
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1295 ;;; as constituting a filename.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1296 ;;;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1297 ;;; 1/90 shivers
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1298 ;;; These changes comprise release 2.02:
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1299 ;;; - Removed the kill-all-local-variables in comint-mode. This
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1300 ;;; made it impossible for client modes to set things before calling
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1301 ;;; comint-mode. (In particular, it messed up ilisp.el) In general,
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1302 ;;; the client mode should be responsible for a k-a-l-v's.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1303 ;;; - Fixed comint-match-partial-pathname so that it works in
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1304 ;;; more cases: if the filename begins at the start-of-buffer;
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1305 ;;; if point is on the first char of the filename. Just a question
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1306 ;;; of getting the tricky bits right.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1307 ;;; - Added a hook, comint-exec-hook that is run each time a process
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1308 ;;; is cranked up. Useful for things like process-kill-without-query.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1309 ;;;
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1310 ;;; These two were pointed out by tale:
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1311 ;;; - Improved the doc string in comint-send-input a little bit.
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1312 ;;; - Tweaked make-comint to check process status with comint-check-proc
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1313 ;;; instead of equivalent inline code.
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1314 ;;;
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1315 ;;; - Prompt-search history commands have been commented out. I never
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1316 ;;; liked them; I don't think anyone used them.
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1317 ;;; - Made comint-exec-hook a local var, as it should have been.
2518
10509afe2588 Clean up cmu* uses in header comments.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2455
diff changeset
1318 ;;; (This way, for instance, you can have shell procs kill-w/o-query,
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1319 ;;; but let Scheme procs be default.)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1320 ;;;
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1321 ;;; 7/91 Shivers
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1322 ;;; - Souped up comint-read-noecho with an optional argument, STARS.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1323 ;;; Suggested by mjlx@EAGLE.CNSF.CORNELL.EDU.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1324 ;;; - Moved comint-previous-input-matching from C-c r to C-M-r.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1325 ;;; C-c <letter> bindings are reserved for the user.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1326 ;;; These bindings were done by Jim Blandy.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1327 ;;; These changes comprise version 2.03.
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1328
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 182
diff changeset
1329 (provide 'comint)
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 638
diff changeset
1330
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 638
diff changeset
1331 ;;; comint.el ends here