Mercurial > emacs
annotate lisp/comint.el @ 16817:40eaf36862f4
Initial revision
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 03 Jan 1997 01:16:16 +0000 |
parents | 2a181da249e0 |
children | ec7768e50ba8 |
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 |
15369
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
3 ;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96 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> |
10445
a657f6491234
Make sure the event read by comint-dynamic-list-completions isn't
Simon Marshall <simon@gnu.org>
parents:
10125
diff
changeset
|
6 ;; Adapted-by: Simon Marshall <simon@gnu.ai.mit.edu> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2025
diff
changeset
|
7 ;; Keywords: processes |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
8 |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
114 | 10 |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
11 ;; 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
|
12 ;; 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
|
13 ;; 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
|
14 ;; any later version. |
114 | 15 |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
16 ;; 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
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
19 ;; GNU General Public License for more details. |
114 | 20 |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
114 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
793
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
793
diff
changeset
|
27 |
14169 | 28 ;; Please send me bug reports, bug fixes, and extensions, so that I can |
29 ;; merge them into the master source. | |
30 ;; - Olin Shivers (shivers@cs.cmu.edu) | |
31 ;; - Simon Marshall (simon@gnu.ai.mit.edu) | |
584 | 32 |
14169 | 33 ;; This file defines a general command-interpreter-in-a-buffer package |
34 ;; (comint mode). The idea is that you can build specific process-in-a-buffer | |
35 ;; modes on top of comint mode -- e.g., lisp, shell, scheme, T, soar, .... | |
36 ;; This way, all these specific packages share a common base functionality, | |
37 ;; and a common set of bindings, which makes them easier to use (and | |
38 ;; saves code, implementation time, etc., etc.). | |
114 | 39 |
14169 | 40 ;; Several packages are already defined using comint mode: |
41 ;; - shell.el defines a shell-in-a-buffer mode. | |
42 ;; - cmulisp.el defines a simple lisp-in-a-buffer mode. | |
43 ;; | |
44 ;; - The file cmuscheme.el defines a scheme-in-a-buffer mode. | |
45 ;; - The file tea.el tunes scheme and inferior-scheme modes for T. | |
46 ;; - The file soar.el tunes lisp and inferior-lisp modes for Soar. | |
47 ;; - cmutex.el defines tex and latex modes that invoke tex, latex, bibtex, | |
48 ;; previewers, and printers from within emacs. | |
49 ;; - background.el allows csh-like job control inside emacs. | |
50 ;; It is pretty easy to make new derived modes for other processes. | |
584 | 51 |
14169 | 52 ;; For documentation on the functionality provided by comint mode, and |
53 ;; the hooks available for customising it, see the comments below. | |
54 ;; For further information on the standard derived modes (shell, | |
55 ;; inferior-lisp, inferior-scheme, ...), see the relevant source files. | |
114 | 56 |
14169 | 57 ;; For hints on converting existing process modes (e.g., tex-mode, |
58 ;; background, dbx, gdb, kermit, prolog, telnet) to use comint-mode | |
59 ;; instead of shell-mode, see the notes at the end of this file. | |
114 | 60 |
61 | |
14169 | 62 ;; Brief Command Documentation: |
63 ;;============================================================================ | |
64 ;; Comint Mode Commands: (common to all derived modes, like shell & cmulisp | |
65 ;; mode) | |
66 ;; | |
67 ;; m-p comint-previous-input Cycle backwards in input history | |
68 ;; m-n comint-next-input Cycle forwards | |
69 ;; m-r comint-previous-matching-input Previous input matching a regexp | |
70 ;; m-s comint-next-matching-input Next input that matches | |
71 ;; m-c-l comint-show-output Show last batch of process output | |
72 ;; return comint-send-input | |
73 ;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff | |
74 ;; c-c c-a comint-bol Beginning of line; skip prompt | |
75 ;; c-c c-u comint-kill-input ^u | |
76 ;; c-c c-w backward-kill-word ^w | |
77 ;; c-c c-c comint-interrupt-subjob ^c | |
78 ;; c-c c-z comint-stop-subjob ^z | |
79 ;; c-c c-\ comint-quit-subjob ^\ | |
80 ;; c-c c-o comint-kill-output Delete last batch of process output | |
81 ;; c-c c-r comint-show-output Show last batch of process output | |
82 ;; c-c c-l comint-dynamic-list-input-ring List input history | |
83 ;; | |
84 ;; Not bound by default in comint-mode (some are in shell mode) | |
85 ;; comint-run Run a program under comint-mode | |
86 ;; send-invisible Read a line w/o echo, and send to proc | |
87 ;; comint-dynamic-complete-filename Complete filename at point. | |
88 ;; comint-dynamic-complete-variable Complete variable name at point. | |
89 ;; comint-dynamic-list-filename-completions List completions in help buffer. | |
90 ;; comint-replace-by-expanded-filename Expand and complete filename at point; | |
91 ;; replace with expanded/completed name. | |
92 ;; comint-replace-by-expanded-history Expand history at point; | |
93 ;; replace with expanded name. | |
94 ;; comint-magic-space Expand history and add (a) space(s). | |
95 ;; comint-kill-subjob No mercy. | |
96 ;; comint-show-maximum-output Show as much output as possible. | |
97 ;; comint-continue-subjob Send CONT signal to buffer's process | |
98 ;; group. Useful if you accidentally | |
99 ;; suspend your process (with C-c C-z). | |
114 | 100 |
14169 | 101 ;; comint-mode-hook is the comint mode hook. Basically for your keybindings. |
584 | 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 |
1131 | 105 (require 'ring) |
114 | 106 |
14169 | 107 ;; Buffer Local Variables: |
108 ;;============================================================================ | |
109 ;; Comint mode buffer local variables: | |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
110 ;; comint-prompt-regexp string comint-bol uses to match prompt |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
111 ;; comint-delimiter-argument-list list For delimiters and arguments |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
112 ;; comint-last-input-start marker Handy if inferior always echoes |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
113 ;; comint-last-input-end marker For comint-kill-output command |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
114 ;; comint-input-ring-size integer For the input history |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
115 ;; comint-input-ring ring mechanism |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
116 ;; comint-input-ring-index number ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
117 ;; comint-input-autoexpand symbol ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
118 ;; comint-input-ignoredups boolean ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
119 ;; comint-last-input-match string ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
120 ;; comint-dynamic-complete-functions hook For the completion mechanism |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
121 ;; comint-completion-fignore list ... |
15817
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
122 ;; comint-file-name-chars string ... |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
123 ;; comint-file-name-quote-list list ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
124 ;; comint-get-old-input function Hooks for specific |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
125 ;; comint-input-filter-functions hook process-in-a-buffer |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
126 ;; comint-output-filter-functions hook function modes. |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
127 ;; comint-input-filter function ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
128 ;; comint-input-sender function ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
129 ;; comint-eol-on-send boolean ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
130 ;; comint-process-echoes boolean ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
131 ;; comint-scroll-to-bottom-on-input symbol For scroll behavior |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
132 ;; comint-scroll-to-bottom-on-output symbol ... |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
133 ;; comint-scroll-show-maximum-output boolean ... |
14169 | 134 ;; |
135 ;; Comint mode non-buffer local variables: | |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
136 ;; comint-completion-addsuffix boolean/cons For file name |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
137 ;; comint-completion-autolist boolean completion behavior |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
138 ;; comint-completion-recexact boolean ... |
114 | 139 |
584 | 140 (defvar comint-prompt-regexp "^" |
141 "Regexp to recognise prompts in the inferior process. | |
142 Defaults to \"^\", the null string at BOL. | |
114 | 143 |
144 Good choices: | |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
145 Canonical Lisp: \"^[^> \\n]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp) |
3985
fc25d1816641
* comint.el (comint-prompt-regexp): Double the backslashes in the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
146 Lucid Common Lisp: \"^\\\\(>\\\\|\\\\(->\\\\)+\\\\) *\" |
fc25d1816641
* comint.el (comint-prompt-regexp): Double the backslashes in the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
147 franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\" |
584 | 148 kcl: \"^>+ *\" |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
149 shell: \"^[^#$%>\\n]*[#$%>] *\" |
584 | 150 T: \"^>+ *\" |
114 | 151 |
584 | 152 This is a good thing to set in mode hooks.") |
114 | 153 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
154 (defvar comint-delimiter-argument-list () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
155 "List of characters to recognise as separate arguments in input. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
156 Strings comprising a character in this list will separate the arguments |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
157 surrounding them, and also be regarded as arguments in their own right (unlike |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
158 whitespace). See `comint-arguments'. |
6154
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
159 Defaults to the empty list. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
160 |
6154
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
161 For shells, a good value is (?\\| ?& ?< ?> ?\\( ?\\) ?;). |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
162 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
163 This is a good thing to set in mode hooks.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
164 |
5539
73389b4a4a9d
(comint-input-autoexpand): Make default nil.
Richard M. Stallman <rms@gnu.org>
parents:
5476
diff
changeset
|
165 (defvar comint-input-autoexpand nil |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
166 "*If non-nil, expand input command history references on completion. |
4923
63aed739d09d
(comint-postoutput-scroll-to-bottom):
Richard M. Stallman <rms@gnu.org>
parents:
4899
diff
changeset
|
167 This mirrors the optional behavior of tcsh (its autoexpand and histlit). |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
168 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
169 If the value is `input', then the expansion is seen on input. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
170 If the value is `history', then the expansion is only when inserting |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
171 into the buffer's input ring. See also `comint-magic-space' and |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
172 `comint-dynamic-complete'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
173 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
174 This variable is buffer-local.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
175 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
176 (defvar comint-input-ignoredups nil |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
177 "*If non-nil, don't add input matching the last on the input ring. |
4923
63aed739d09d
(comint-postoutput-scroll-to-bottom):
Richard M. Stallman <rms@gnu.org>
parents:
4899
diff
changeset
|
178 This mirrors the optional behavior of bash. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
179 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
180 This variable is buffer-local.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
181 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
182 (defvar comint-input-ring-file-name nil |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
183 "*If non-nil, name of the file to read/write input history. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
184 See also `comint-read-input-ring' and `comint-write-input-ring'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
185 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
186 This variable is buffer-local, and is a good thing to set in mode hooks.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
187 |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
188 (defvar comint-scroll-to-bottom-on-input nil |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
189 "*Controls whether input to interpreter causes window to scroll. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
190 If nil, then do not scroll. If t or `all', scroll all windows showing buffer. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
191 If `this', scroll only the selected window. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
192 |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
193 The default is nil. |
4880
a658d0e341b1
(comint-scroll-to-bottom-on-input)
Richard M. Stallman <rms@gnu.org>
parents:
4872
diff
changeset
|
194 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
195 See `comint-preinput-scroll-to-bottom'. This variable is buffer-local.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
196 |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
197 (defvar comint-scroll-to-bottom-on-output nil |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
198 "*Controls whether interpreter output causes window to scroll. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
199 If nil, then do not scroll. If t or `all', scroll all windows showing buffer. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
200 If `this', scroll only the selected window. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
201 If `others', scroll only those that are not the selected window. |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
202 |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
203 The default is nil. |
4880
a658d0e341b1
(comint-scroll-to-bottom-on-input)
Richard M. Stallman <rms@gnu.org>
parents:
4872
diff
changeset
|
204 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
205 See variable `comint-scroll-show-maximum-output' and function |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
206 `comint-postoutput-scroll-to-bottom'. This variable is buffer-local.") |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
207 |
5058
fb8f2a3f2178
(comint-scroll-show-maximum-output): Make default nil.
Richard M. Stallman <rms@gnu.org>
parents:
5050
diff
changeset
|
208 (defvar comint-scroll-show-maximum-output nil |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
209 "*Controls how interpreter output causes window to scroll. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
210 If non-nil, then show the maximum output when the window is scrolled. |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
211 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
212 See variable `comint-scroll-to-bottom-on-output' and function |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
213 `comint-postoutput-scroll-to-bottom'. This variable is buffer-local.") |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
214 |
10833
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
215 (defvar comint-buffer-maximum-size 1024 |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
216 "*The maximum size in lines for comint buffers. |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
217 Comint buffers are truncated from the top to be no greater than this number, if |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
218 the function `comint-truncate-buffer' is on `comint-output-filter-functions'.") |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
219 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
220 (defvar comint-input-ring-size 32 |
584 | 221 "Size of input history ring.") |
114 | 222 |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
223 (defvar comint-process-echoes nil |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
224 "*If non-nil, assume that the subprocess echoes any input. |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
225 If so, delete one copy of the input so that only one copy eventually |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
226 appears in the buffer. |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
227 |
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
228 This variable is buffer-local.") |
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
229 |
8400
cc016ca78c9e
(comint-password-prompt-regexp): Handle PGP prompt.
Richard M. Stallman <rms@gnu.org>
parents:
8332
diff
changeset
|
230 (defvar comint-password-prompt-regexp |
16584
2a181da249e0
(comint-password-prompt-regexp): Recognize AIX format.
Karl Heuer <kwzh@gnu.org>
parents:
16546
diff
changeset
|
231 "\\(\\([Oo]ld \\|[Nn]ew \\|'s \\|^\\)[Pp]assword\\|pass phrase\\):\\s *\\'" |
8087
c22d7c5168f5
comint-password-prompt-regexp: New variable.
Noah Friedman <friedman@splode.com>
parents:
8060
diff
changeset
|
232 "*Regexp matching prompts for passwords in the inferior process. |
8400
cc016ca78c9e
(comint-password-prompt-regexp): Handle PGP prompt.
Richard M. Stallman <rms@gnu.org>
parents:
8332
diff
changeset
|
233 This is used by `comint-watch-for-password-prompt'.") |
8087
c22d7c5168f5
comint-password-prompt-regexp: New variable.
Noah Friedman <friedman@splode.com>
parents:
8060
diff
changeset
|
234 |
14169 | 235 ;; Here are the per-interpreter hooks. |
584 | 236 (defvar comint-get-old-input (function comint-get-old-input-default) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
237 "Function that returns old text in comint mode. |
114 | 238 This function is called when return is typed while the point is in old text. |
239 It returns the text to be submitted as process input. The default is | |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
240 `comint-get-old-input-default', which grabs the current line, and strips off |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
241 leading text matching `comint-prompt-regexp'.") |
114 | 242 |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
243 (defvar comint-dynamic-complete-functions |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
244 '(comint-replace-by-expanded-history comint-dynamic-complete-filename) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
245 "List of functions called to perform completion. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
246 Functions should return non-nil if completion was performed. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
247 See also `comint-dynamic-complete'. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
248 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
249 This is a good thing to set in mode hooks.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
250 |
584 | 251 (defvar comint-input-filter |
252 (function (lambda (str) (not (string-match "\\`\\s *\\'" str)))) | |
253 "Predicate for filtering additions to input history. | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
254 Takes one argument, the input. If non-nil, the input may be saved on the input |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
255 history list. Default is to save anything that isn't all whitespace.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
256 |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
257 (defvar comint-input-filter-functions '() |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
258 "Functions to call before input is sent to the process. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
259 These functions get one argument, a string containing the text to send. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
260 |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
261 This variable is buffer-local.") |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
262 |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
263 (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
264 "Functions to call after output is inserted into the buffer. |
4890
dab300dfe449
(comint-scroll-to-bottom-on-input): Default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4880
diff
changeset
|
265 One possible function is `comint-postoutput-scroll-to-bottom'. |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
266 These functions get one argument, a string containing the text as originally |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
267 inserted. Note that this might not be the same as the buffer contents between |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
268 `comint-last-output-start' and the buffer's `process-mark', if other filter |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
269 functions have already modified the buffer. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
270 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
271 This variable is buffer-local.") |
584 | 272 |
273 (defvar comint-input-sender (function comint-simple-send) | |
274 "Function to actually send to PROCESS the STRING submitted by user. | |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
275 Usually this is just `comint-simple-send', but if your mode needs to |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
276 massage the input string, put a different function here. |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
277 `comint-simple-send' just sends the string plus a newline. |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
278 This is called from the user command `comint-send-input'.") |
584 | 279 |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
280 (defvar comint-eol-on-send t |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
281 "*Non-nil means go to the end of the line before sending input. |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
282 See `comint-send-input'.") |
114 | 283 |
284 (defvar comint-mode-hook '() | |
584 | 285 "Called upon entry into comint-mode |
286 This is run before the process is cranked up.") | |
287 | |
288 (defvar comint-exec-hook '() | |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
289 "Called each time a process is exec'd by `comint-exec'. |
584 | 290 This is called after the process is cranked up. It is useful for things that |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
291 must be done each time a process is executed in a comint mode buffer (e.g., |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
292 `(process-kill-without-query)'). In contrast, the `comint-mode-hook' is only |
584 | 293 executed once when the buffer is created.") |
294 | |
295 (defvar comint-mode-map nil) | |
114 | 296 |
1131 | 297 (defvar comint-ptyp t |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
298 "Non-nil if communications via pty; false if by pipe. Buffer local. |
13971
49207f2e2130
(comint-ptyp, comint-completion-autolist): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13702
diff
changeset
|
299 This is to work around a bug in Emacs process signaling.") |
1131 | 300 |
932
a93f0b1ba909
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
925
diff
changeset
|
301 (defvar comint-input-ring nil) |
861
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
302 (defvar comint-last-input-start) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
303 (defvar comint-last-input-end) |
5424
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
304 (defvar comint-last-output-start) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
305 (defvar comint-input-ring-index nil |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
306 "Index of last matched history element.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
307 (defvar comint-matching-input-from-input-string "" |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
308 "Input previously used to match input history.") |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
309 |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
310 (put 'comint-replace-by-expanded-history 'menu-enable 'comint-input-autoexpand) |
1131 | 311 (put 'comint-input-ring 'permanent-local t) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
312 (put 'comint-input-ring-index 'permanent-local t) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
313 (put 'comint-input-autoexpand 'permanent-local t) |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
314 (put 'comint-input-filter-functions 'permanent-local t) |
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
315 (put 'comint-output-filter-functions 'permanent-local t) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
316 (put 'comint-scroll-to-bottom-on-input 'permanent-local t) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
317 (put 'comint-scroll-to-bottom-on-output 'permanent-local t) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
318 (put 'comint-scroll-show-maximum-output 'permanent-local t) |
1131 | 319 (put 'comint-ptyp 'permanent-local t) |
861
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
320 |
114 | 321 (defun comint-mode () |
322 "Major mode for interacting with an inferior interpreter. | |
323 Interpreter name is same as buffer name, sans the asterisks. | |
324 Return at end of buffer sends line as input. | |
325 Return not at end copies rest of line to end and sends it. | |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
326 Setting variable `comint-eol-on-send' means jump to the end of the line |
584 | 327 before submitting new input. |
114 | 328 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
329 This mode is customised to create major modes such as Inferior Lisp |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
330 mode, Shell mode, etc. This can be done by setting the hooks |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
331 `comint-input-filter-functions', `comint-input-filter', `comint-input-sender' |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
332 and `comint-get-old-input' to appropriate functions, and the variable |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
333 `comint-prompt-regexp' to the appropriate regular expression. |
114 | 334 |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
335 An input history is maintained of size `comint-input-ring-size', and |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
336 can be accessed with the commands \\[comint-next-input], \\[comint-previous-input], and \\[comint-dynamic-list-input-ring]. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
337 Input ring history expansion can be achieved with the commands |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
338 \\[comint-replace-by-expanded-history] or \\[comint-magic-space]. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
339 Input ring expansion is controlled by the variable `comint-input-autoexpand', |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
340 and addition is controlled by the variable `comint-input-ignoredups'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
341 |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
342 Commands with no default key bindings include `send-invisible', |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
343 `comint-dynamic-complete', `comint-dynamic-list-filename-completions', and |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
344 `comint-magic-space'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
345 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
346 Input to, and output from, the subprocess can cause the window to scroll to |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
347 the end of the buffer. See variables `comint-output-filter-functions', |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
348 `comint-scroll-to-bottom-on-input', and `comint-scroll-to-bottom-on-output'. |
114 | 349 |
350 If you accidentally suspend your process, use \\[comint-continue-subjob] | |
351 to continue it. | |
352 | |
353 \\{comint-mode-map} | |
354 | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
355 Entry to this mode runs the hooks on `comint-mode-hook'." |
114 | 356 (interactive) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
357 ;; Do not remove this. All major modes must do this. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
358 (kill-all-local-variables) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
359 (setq major-mode 'comint-mode) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
360 (setq mode-name "Comint") |
7071
058f19d36c07
(comint-mode): Remove space after `:' in mode-line-process.
Richard M. Stallman <rms@gnu.org>
parents:
7048
diff
changeset
|
361 (setq mode-line-process '(":%s")) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
362 (use-local-map comint-mode-map) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
363 (make-local-variable 'comint-last-input-start) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
364 (setq comint-last-input-start (make-marker)) |
6998
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
365 (set-marker comint-last-input-start (point-min)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
366 (make-local-variable 'comint-last-input-end) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
367 (setq comint-last-input-end (make-marker)) |
6998
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
368 (set-marker comint-last-input-end (point-min)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
369 (make-local-variable 'comint-last-output-start) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
370 (setq comint-last-output-start (make-marker)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
371 (make-local-variable 'comint-prompt-regexp) ; Don't set; default |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
372 (make-local-variable 'comint-input-ring-size) ; ...to global val. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
373 (make-local-variable 'comint-input-ring) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
374 (make-local-variable 'comint-input-ring-file-name) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
375 (or (and (boundp 'comint-input-ring) comint-input-ring) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
376 (setq comint-input-ring (make-ring comint-input-ring-size))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
377 (make-local-variable 'comint-input-ring-index) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
378 (or (and (boundp 'comint-input-ring-index) comint-input-ring-index) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
379 (setq comint-input-ring-index nil)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
380 (make-local-variable 'comint-matching-input-from-input-string) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
381 (make-local-variable 'comint-input-autoexpand) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
382 (make-local-variable 'comint-input-ignoredups) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
383 (make-local-variable 'comint-delimiter-argument-list) |
12208
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
384 (make-local-hook 'comint-dynamic-complete-functions) |
6256
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
385 (make-local-variable 'comint-completion-fignore) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
386 (make-local-variable 'comint-get-old-input) |
12208
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
387 (make-local-hook 'comint-input-filter-functions) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
388 (make-local-variable 'comint-input-filter) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
389 (make-local-variable 'comint-input-sender) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
390 (make-local-variable 'comint-eol-on-send) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
391 (make-local-variable 'comint-scroll-to-bottom-on-input) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
392 (make-local-variable 'comint-scroll-to-bottom-on-output) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
393 (make-local-variable 'comint-scroll-show-maximum-output) |
4890
dab300dfe449
(comint-scroll-to-bottom-on-input): Default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4880
diff
changeset
|
394 (make-local-variable 'pre-command-hook) |
dab300dfe449
(comint-scroll-to-bottom-on-input): Default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4880
diff
changeset
|
395 (add-hook 'pre-command-hook 'comint-preinput-scroll-to-bottom) |
12208
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
396 (make-local-hook 'comint-output-filter-functions) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
397 (make-local-variable 'comint-ptyp) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
398 (make-local-variable 'comint-exec-hook) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
399 (make-local-variable 'comint-process-echoes) |
15817
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
400 (make-local-variable 'comint-file-name-chars) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
401 (make-local-variable 'comint-file-name-quote-list) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
402 (run-hooks 'comint-mode-hook)) |
114 | 403 |
584 | 404 (if comint-mode-map |
405 nil | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
406 ;; Keys: |
584 | 407 (setq comint-mode-map (make-sparse-keymap)) |
408 (define-key comint-mode-map "\ep" 'comint-previous-input) | |
409 (define-key comint-mode-map "\en" 'comint-next-input) | |
10125
317294dfa695
(comint-mode-map): Treat C-up, C-down like M-p, M-n.
Richard M. Stallman <rms@gnu.org>
parents:
9919
diff
changeset
|
410 (define-key comint-mode-map [C-up] 'comint-previous-input) |
317294dfa695
(comint-mode-map): Treat C-up, C-down like M-p, M-n.
Richard M. Stallman <rms@gnu.org>
parents:
9919
diff
changeset
|
411 (define-key comint-mode-map [C-down] 'comint-next-input) |
2673
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
412 (define-key comint-mode-map "\er" 'comint-previous-matching-input) |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
413 (define-key comint-mode-map "\es" 'comint-next-matching-input) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
414 (define-key comint-mode-map [?\A-\M-r] 'comint-previous-matching-input-from-input) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
415 (define-key comint-mode-map [?\A-\M-s] 'comint-next-matching-input-from-input) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
416 (define-key comint-mode-map "\e\C-l" 'comint-show-output) |
584 | 417 (define-key comint-mode-map "\C-m" 'comint-send-input) |
418 (define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof) | |
8265
c830f54843c2
(comint-mode-map): Move comint-bol to C-c C-a.
Richard M. Stallman <rms@gnu.org>
parents:
8087
diff
changeset
|
419 (define-key comint-mode-map "\C-c\C-a" 'comint-bol) |
584 | 420 (define-key comint-mode-map "\C-c\C-u" 'comint-kill-input) |
421 (define-key comint-mode-map "\C-c\C-w" 'backward-kill-word) | |
422 (define-key comint-mode-map "\C-c\C-c" 'comint-interrupt-subjob) | |
423 (define-key comint-mode-map "\C-c\C-z" 'comint-stop-subjob) | |
424 (define-key comint-mode-map "\C-c\C-\\" 'comint-quit-subjob) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
425 (define-key comint-mode-map "\C-c\C-m" 'comint-copy-old-input) |
584 | 426 (define-key comint-mode-map "\C-c\C-o" 'comint-kill-output) |
427 (define-key comint-mode-map "\C-c\C-r" 'comint-show-output) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
428 (define-key comint-mode-map "\C-c\C-e" 'comint-show-maximum-output) |
7048
d4575065e6aa
(comint-mode-map): comint-dynamic-list-input-ring now on C-c C-l.
Richard M. Stallman <rms@gnu.org>
parents:
6998
diff
changeset
|
429 (define-key comint-mode-map "\C-c\C-l" 'comint-dynamic-list-input-ring) |
4112
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
430 (define-key comint-mode-map "\C-c\C-n" 'comint-next-prompt) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
431 (define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt) |
4112
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
432 (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
433 ;; Menu bars: |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
434 ;; completion: |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
435 (define-key comint-mode-map [menu-bar completion] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
436 (cons "Complete" (make-sparse-keymap "Complete"))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
437 (define-key comint-mode-map [menu-bar completion complete-expand] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
438 '("Expand File Name" . comint-replace-by-expanded-filename)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
439 (define-key comint-mode-map [menu-bar completion complete-listing] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
440 '("File Completion Listing" . comint-dynamic-list-filename-completions)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
441 (define-key comint-mode-map [menu-bar completion complete-file] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
442 '("Complete File Name" . comint-dynamic-complete-filename)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
443 (define-key comint-mode-map [menu-bar completion complete] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
444 '("Complete Before Point" . comint-dynamic-complete)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
445 ;; Input history: |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
446 (define-key comint-mode-map [menu-bar inout] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
447 (cons "In/Out" (make-sparse-keymap "In/Out"))) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
448 (define-key comint-mode-map [menu-bar inout kill-output] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
449 '("Kill Current Output Group" . comint-kill-output)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
450 (define-key comint-mode-map [menu-bar inout next-prompt] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
451 '("Forward Output Group" . comint-next-prompt)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
452 (define-key comint-mode-map [menu-bar inout previous-prompt] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
453 '("Backward Output Group" . comint-previous-prompt)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
454 (define-key comint-mode-map [menu-bar inout show-maximum-output] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
455 '("Show Maximum Output" . comint-show-maximum-output)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
456 (define-key comint-mode-map [menu-bar inout show-output] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
457 '("Show Current Output Group" . comint-show-output)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
458 (define-key comint-mode-map [menu-bar inout kill-input] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
459 '("Kill Current Input" . comint-kill-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
460 (define-key comint-mode-map [menu-bar inout copy-input] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
461 '("Copy Old Input" . comint-copy-old-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
462 (define-key comint-mode-map [menu-bar inout forward-matching-history] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
463 '("Forward Matching Input..." . comint-forward-matching-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
464 (define-key comint-mode-map [menu-bar inout backward-matching-history] |
4899
3b157c1195a6
(comint-mode-map): Merge menu bar item Output into Input.
Richard M. Stallman <rms@gnu.org>
parents:
4890
diff
changeset
|
465 '("Backward Matching Input..." . comint-backward-matching-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
466 (define-key comint-mode-map [menu-bar inout next-matching-history] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
467 '("Next Matching Input..." . comint-next-matching-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
468 (define-key comint-mode-map [menu-bar inout previous-matching-history] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
469 '("Previous Matching Input..." . comint-previous-matching-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
470 (define-key comint-mode-map [menu-bar inout next-matching-history-from-input] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
471 '("Next Matching Current Input" . comint-next-matching-input-from-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
472 (define-key comint-mode-map [menu-bar inout previous-matching-history-from-input] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
473 '("Previous Matching Current Input" . comint-previous-matching-input-from-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
474 (define-key comint-mode-map [menu-bar inout next-history] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
475 '("Next Input" . comint-next-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
476 (define-key comint-mode-map [menu-bar inout previous-history] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
477 '("Previous Input" . comint-previous-input)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
478 (define-key comint-mode-map [menu-bar inout list-history] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
479 '("List Input History" . comint-dynamic-list-input-ring)) |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
480 (define-key comint-mode-map [menu-bar inout expand-history] |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
481 '("Expand History Before Point" . comint-replace-by-expanded-history)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
482 ;; Signals |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
483 (define-key comint-mode-map [menu-bar signals] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
484 (cons "Signals" (make-sparse-keymap "Signals"))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
485 (define-key comint-mode-map [menu-bar signals eof] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
486 '("EOF" . comint-send-eof)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
487 (define-key comint-mode-map [menu-bar signals kill] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
488 '("KILL" . comint-kill-subjob)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
489 (define-key comint-mode-map [menu-bar signals quit] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
490 '("QUIT" . comint-quit-subjob)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
491 (define-key comint-mode-map [menu-bar signals cont] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
492 '("CONT" . comint-continue-subjob)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
493 (define-key comint-mode-map [menu-bar signals stop] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
494 '("STOP" . comint-stop-subjob)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
495 (define-key comint-mode-map [menu-bar signals break] |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
496 '("BREAK" . comint-interrupt-subjob)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
497 ;; Put them in the menu bar: |
6148
ec063baec3e0
(full-copy-sparse-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
6095
diff
changeset
|
498 (setq menu-bar-final-items (append '(completion inout signals) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
499 menu-bar-final-items)) |
584 | 500 ) |
501 | |
502 (defun comint-check-proc (buffer) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
503 "Return t if there is a living process associated w/buffer BUFFER. |
9388
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
504 Living means the status is `open', `run', or `stop'. |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
505 BUFFER can be either a buffer or the name of one." |
584 | 506 (let ((proc (get-buffer-process buffer))) |
9388
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
507 (and proc (memq (process-status proc) '(open run stop))))) |
114 | 508 |
14169 | 509 ;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it () |
510 ;; for the second argument (program). | |
14644
325bc6726a7b
(make-comint, comint-run): Fix autoload cookie.
Erik Naggum <erik@naggum.no>
parents:
14169
diff
changeset
|
511 ;;;###autoload |
114 | 512 (defun make-comint (name program &optional startfile &rest switches) |
1839
e10cdcb857d2
(make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents:
1821
diff
changeset
|
513 "Make a comint process NAME in a buffer, running PROGRAM. |
e10cdcb857d2
(make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents:
1821
diff
changeset
|
514 The name of the buffer is made by surrounding NAME with `*'s. |
9388
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
515 PROGRAM should be either a string denoting an executable program to create |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
516 via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
517 connection to be opened via `open-network-stream'. If there is already a |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
518 running process in that buffer, it is not restarted. Optional third arg |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
519 STARTFILE is the name of a file to send the contents of to the process. |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
520 |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
521 If PROGRAM is a string, any more args are arguments to PROGRAM." |
11310
3466b44b0a11
(make-comint): Error, if start-process is not fboundp.
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
522 (or (fboundp 'start-process) |
3466b44b0a11
(make-comint): Error, if start-process is not fboundp.
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
523 (error "Multi-processing is not supported for this system")) |
584 | 524 (let ((buffer (get-buffer-create (concat "*" name "*")))) |
114 | 525 ;; 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
|
526 ;; comint mode. Otherwise, leave buffer and existing process alone. |
182 | 527 (cond ((not (comint-check-proc buffer)) |
584 | 528 (save-excursion |
114 | 529 (set-buffer buffer) |
530 (comint-mode)) ; Install local vars, mode, keymap, ... | |
531 (comint-exec buffer name program startfile switches))) | |
532 buffer)) | |
533 | |
14644
325bc6726a7b
(make-comint, comint-run): Fix autoload cookie.
Erik Naggum <erik@naggum.no>
parents:
14169
diff
changeset
|
534 ;;;###autoload |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
535 (defun comint-run (program) |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
536 "Run PROGRAM in a comint buffer and switch to it. |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
537 The buffer name is made by surrounding the file name of PROGRAM with `*'s. |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
538 The file name is used to make a symbol name, such as `comint-sh-hook', and any |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
539 hooks on this symbol are run in the buffer. |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
540 See `make-comint' and `comint-exec'." |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
541 (interactive "sRun program: ") |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
542 (let ((name (file-name-nondirectory program))) |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
543 (switch-to-buffer (make-comint name program)) |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
544 (run-hooks (intern-soft (concat "comint-" name "-hook"))))) |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
545 |
114 | 546 (defun comint-exec (buffer name command startfile switches) |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
547 "Start up a process in buffer BUFFER for comint modes. |
1839
e10cdcb857d2
(make-comint): Added docstring.
Roland McGrath <roland@gnu.org>
parents:
1821
diff
changeset
|
548 Blasts any old process running in the buffer. Doesn't set the buffer mode. |
584 | 549 You can use this to cheaply run a series of processes in the same comint |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
550 buffer. The hook `comint-exec-hook' is run after each exec." |
114 | 551 (save-excursion |
552 (set-buffer buffer) | |
553 (let ((proc (get-buffer-process buffer))) ; Blast any old process. | |
554 (if proc (delete-process proc))) | |
555 ;; Crank up a new process | |
9388
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
556 (let ((proc |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
557 (if (consp command) |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
558 (open-network-stream name buffer (car command) (cdr command)) |
c9b5541ec9f5
(comint-check-proc): Recognise `open'.
Richard M. Stallman <rms@gnu.org>
parents:
9245
diff
changeset
|
559 (comint-exec-1 name buffer command switches)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
560 (set-process-filter proc 'comint-output-filter) |
584 | 561 (make-local-variable 'comint-ptyp) |
562 (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe. | |
114 | 563 ;; Jump to the end, and set the process mark. |
584 | 564 (goto-char (point-max)) |
705 | 565 (set-marker (process-mark proc) (point)) |
114 | 566 ;; Feed it the startfile. |
567 (cond (startfile | |
568 ;;This is guaranteed to wait long enough | |
569 ;;but has bad results if the comint does not prompt at all | |
570 ;; (while (= size (buffer-size)) | |
571 ;; (sleep-for 1)) | |
572 ;;I hope 1 second is enough! | |
573 (sleep-for 1) | |
574 (goto-char (point-max)) | |
575 (insert-file-contents startfile) | |
576 (setq startfile (buffer-substring (point) (point-max))) | |
577 (delete-region (point) (point-max)) | |
584 | 578 (comint-send-string proc startfile))) |
579 (run-hooks 'comint-exec-hook) | |
705 | 580 buffer))) |
114 | 581 |
14169 | 582 ;; This auxiliary function cranks up the process for comint-exec in |
583 ;; the appropriate environment. | |
114 | 584 |
585 (defun comint-exec-1 (name buffer command switches) | |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
586 (let ((process-environment |
6750
a864110c6fc7
(comint-exec-1): Handle both termcap and terminfo.
Karl Heuer <kwzh@gnu.org>
parents:
6507
diff
changeset
|
587 (nconc |
7327 | 588 ;; If using termcap, we specify `emacs' as the terminal type |
589 ;; because that lets us specify a width. | |
14814
3793008500cd
(comint-exec-1): Use dumb instead of unknown, for terminfo.
Richard M. Stallman <rms@gnu.org>
parents:
14644
diff
changeset
|
590 ;; If using terminfo, we specify `dumb' because that is |
7327 | 591 ;; a defined terminal type. `emacs' is not a defined terminal type |
592 ;; and there is no way for us to define it here. | |
593 ;; Some programs that use terminfo get very confused | |
594 ;; if TERM is not a valid terminal type. | |
6750
a864110c6fc7
(comint-exec-1): Handle both termcap and terminfo.
Karl Heuer <kwzh@gnu.org>
parents:
6507
diff
changeset
|
595 (if (and (boundp 'system-uses-terminfo) system-uses-terminfo) |
14814
3793008500cd
(comint-exec-1): Use dumb instead of unknown, for terminfo.
Richard M. Stallman <rms@gnu.org>
parents:
14644
diff
changeset
|
596 (list "TERM=dumb" |
6750
a864110c6fc7
(comint-exec-1): Handle both termcap and terminfo.
Karl Heuer <kwzh@gnu.org>
parents:
6507
diff
changeset
|
597 (format "COLUMNS=%d" (frame-width))) |
13271
6a084ce822e0
(comint-exec-1): Don't alter EMACS envvar if it's already defined.
Richard M. Stallman <rms@gnu.org>
parents:
13094
diff
changeset
|
598 (list "TERM=emacs" |
9919
08efed8251d6
(comint-exec-1): Terminate TERMCAP with colon.
Richard M. Stallman <rms@gnu.org>
parents:
9873
diff
changeset
|
599 (format "TERMCAP=emacs:co#%d:tc=unknown:" (frame-width)))) |
13271
6a084ce822e0
(comint-exec-1): Don't alter EMACS envvar if it's already defined.
Richard M. Stallman <rms@gnu.org>
parents:
13094
diff
changeset
|
600 (if (getenv "EMACS") nil (list "EMACS=t")) |
9873
03f3cfdb6a11
(comint-exec-1): Make sure default-directory is a real dir.
Richard M. Stallman <rms@gnu.org>
parents:
9764
diff
changeset
|
601 process-environment)) |
03f3cfdb6a11
(comint-exec-1): Make sure default-directory is a real dir.
Richard M. Stallman <rms@gnu.org>
parents:
9764
diff
changeset
|
602 (default-directory |
03f3cfdb6a11
(comint-exec-1): Make sure default-directory is a real dir.
Richard M. Stallman <rms@gnu.org>
parents:
9764
diff
changeset
|
603 (if (file-directory-p default-directory) |
03f3cfdb6a11
(comint-exec-1): Make sure default-directory is a real dir.
Richard M. Stallman <rms@gnu.org>
parents:
9764
diff
changeset
|
604 default-directory |
03f3cfdb6a11
(comint-exec-1): Make sure default-directory is a real dir.
Richard M. Stallman <rms@gnu.org>
parents:
9764
diff
changeset
|
605 "/"))) |
638 | 606 (apply 'start-process name buffer command switches))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
607 |
14169 | 608 ;; Input history processing in a buffer |
609 ;; =========================================================================== | |
610 ;; Useful input history functions, courtesy of the Ergo group. | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
611 |
14169 | 612 ;; Eleven commands: |
613 ;; comint-dynamic-list-input-ring List history in help buffer. | |
614 ;; comint-previous-input Previous input... | |
615 ;; comint-previous-matching-input ...matching a string. | |
616 ;; comint-previous-matching-input-from-input ... matching the current input. | |
617 ;; comint-next-input Next input... | |
618 ;; comint-next-matching-input ...matching a string. | |
619 ;; comint-next-matching-input-from-input ... matching the current input. | |
620 ;; comint-backward-matching-input Backwards input... | |
621 ;; comint-forward-matching-input ...matching a string. | |
622 ;; comint-replace-by-expanded-history Expand history at point; | |
623 ;; replace with expanded history. | |
624 ;; comint-magic-space Expand history and insert space. | |
625 ;; | |
626 ;; Three functions: | |
627 ;; comint-read-input-ring Read into comint-input-ring... | |
628 ;; comint-write-input-ring Write to comint-input-ring-file-name. | |
629 ;; comint-replace-by-expanded-history-before-point Workhorse function. | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
630 |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
631 (defun comint-read-input-ring (&optional silent) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
632 "Sets the buffer's `comint-input-ring' from a history file. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
633 The name of the file is given by the variable `comint-input-ring-file-name'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
634 The history ring is of size `comint-input-ring-size', regardless of file size. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
635 If `comint-input-ring-file-name' is nil this function does nothing. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
636 |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
637 If the optional argument SILENT is non-nil, we say nothing about a |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
638 failure to read the history file. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
639 |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
640 This function is useful for major mode commands and mode hooks. |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
641 |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
642 The structure of the history file should be one input command per line, |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
643 with the most recent command last. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
644 See also `comint-input-ignoredups' and `comint-write-input-ring'." |
5016
11f0a3153f63
(comint-read-input-ring, comint-write-input-ring):
Richard M. Stallman <rms@gnu.org>
parents:
4993
diff
changeset
|
645 (cond ((or (null comint-input-ring-file-name) |
11f0a3153f63
(comint-read-input-ring, comint-write-input-ring):
Richard M. Stallman <rms@gnu.org>
parents:
4993
diff
changeset
|
646 (equal comint-input-ring-file-name "")) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
647 nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
648 ((not (file-readable-p comint-input-ring-file-name)) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
649 (or silent |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
650 (message "Cannot read history file %s" |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
651 comint-input-ring-file-name))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
652 (t |
8032
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
653 (let ((history-buf (get-buffer-create " *temp*")) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
654 (file comint-input-ring-file-name) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
655 (count 0) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
656 (ring (make-ring comint-input-ring-size))) |
8032
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
657 (unwind-protect |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
658 (save-excursion |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
659 (set-buffer history-buf) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
660 (widen) |
8032
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
661 (erase-buffer) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
662 (insert-file-contents file) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
663 ;; Save restriction in case file is already visited... |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
664 ;; Watch for those date stamps in history files! |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
665 (goto-char (point-max)) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
666 (while (and (< count comint-input-ring-size) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
667 (re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$" |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
668 nil t)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
669 (let ((history (buffer-substring (match-beginning 1) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
670 (match-end 1)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
671 (if (or (null comint-input-ignoredups) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
672 (ring-empty-p ring) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
673 (not (string-equal (ring-ref ring 0) history))) |
8032
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
674 (ring-insert-at-beginning ring history))) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
675 (setq count (1+ count)))) |
936532a595dd
(comint-read-input-ring): Use ring-insert-at-beginning.
Richard M. Stallman <rms@gnu.org>
parents:
7846
diff
changeset
|
676 (kill-buffer history-buf)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
677 (setq comint-input-ring ring |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
678 comint-input-ring-index nil))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
679 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
680 (defun comint-write-input-ring () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
681 "Writes the buffer's `comint-input-ring' to a history file. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
682 The name of the file is given by the variable `comint-input-ring-file-name'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
683 The original contents of the file are lost if `comint-input-ring' is not empty. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
684 If `comint-input-ring-file-name' is nil this function does nothing. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
685 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
686 Useful within process sentinels. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
687 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
688 See also `comint-read-input-ring'." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
689 (cond ((or (null comint-input-ring-file-name) |
5016
11f0a3153f63
(comint-read-input-ring, comint-write-input-ring):
Richard M. Stallman <rms@gnu.org>
parents:
4993
diff
changeset
|
690 (equal comint-input-ring-file-name "") |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
691 (null comint-input-ring) (ring-empty-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
692 nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
693 ((not (file-writable-p comint-input-ring-file-name)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
694 (message "Cannot write history file %s" comint-input-ring-file-name)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
695 (t |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
696 (let* ((history-buf (get-buffer-create " *Temp Input History*")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
697 (ring comint-input-ring) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
698 (file comint-input-ring-file-name) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
699 (index (ring-length ring))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
700 ;; Write it all out into a buffer first. Much faster, but messier, |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
701 ;; than writing it one line at a time. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
702 (save-excursion |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
703 (set-buffer history-buf) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
704 (erase-buffer) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
705 (while (> index 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
706 (setq index (1- index)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
707 (insert (ring-ref ring index) ?\n)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
708 (write-region (buffer-string) nil file nil 'no-message) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
709 (kill-buffer nil)))))) |
584 | 710 |
114 | 711 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
712 (defun comint-dynamic-list-input-ring () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
713 "List in help buffer the buffer's input history." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
714 (interactive) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
715 (if (or (not (ring-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
716 (ring-empty-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
717 (message "No history") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
718 (let ((history nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
719 (history-buffer " *Input History*") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
720 (index (1- (ring-length comint-input-ring))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
721 (conf (current-window-configuration))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
722 ;; We have to build up a list ourselves from the ring vector. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
723 (while (>= index 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
724 (setq history (cons (ring-ref comint-input-ring index) history) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
725 index (1- index))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
726 ;; Change "completion" to "history reference" |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
727 ;; to make the display accurate. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
728 (with-output-to-temp-buffer history-buffer |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
729 (display-completion-list history) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
730 (set-buffer history-buffer) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
731 (forward-line 3) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
732 (while (search-backward "completion" nil 'move) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
733 (replace-match "history reference"))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
734 (sit-for 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
735 (message "Hit space to flush") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
736 (let ((ch (read-event))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
737 (if (eq ch ?\ ) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
738 (set-window-configuration conf) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
739 (setq unread-command-events (list ch))))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
740 |
584 | 741 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
742 (defun comint-regexp-arg (prompt) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
743 ;; Return list of regexp and prefix arg using PROMPT. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
744 (let* ((minibuffer-history-sexp-flag nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
745 ;; Don't clobber this. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
746 (last-command last-command) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
747 (regexp (read-from-minibuffer prompt nil nil nil |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
748 'minibuffer-history-search-history))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
749 (list (if (string-equal regexp "") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
750 (setcar minibuffer-history-search-history |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
751 (nth 1 minibuffer-history-search-history)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
752 regexp) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
753 (prefix-numeric-value current-prefix-arg)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
754 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
755 (defun comint-search-arg (arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
756 ;; First make sure there is a ring and that we are after the process mark |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
757 (cond ((not (comint-after-pmark-p)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
758 (error "Not at command line")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
759 ((or (null comint-input-ring) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
760 (ring-empty-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
761 (error "Empty input ring")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
762 ((zerop arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
763 ;; arg of zero resets search from beginning, and uses arg of 1 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
764 (setq comint-input-ring-index nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
765 1) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
766 (t |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
767 arg))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
768 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
769 (defun comint-search-start (arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
770 ;; Index to start a directional search, starting at comint-input-ring-index |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
771 (if comint-input-ring-index |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
772 ;; If a search is running, offset by 1 in direction of arg |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
773 (mod (+ comint-input-ring-index (if (> arg 0) 1 -1)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
774 (ring-length comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
775 ;; For a new search, start from beginning or end, as appropriate |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
776 (if (>= arg 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
777 0 ; First elt for forward search |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
778 (1- (ring-length comint-input-ring))))) ; Last elt for backward search |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
779 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
780 (defun comint-previous-input-string (arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
781 "Return the string ARG places along the input ring. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
782 Moves relative to `comint-input-ring-index'." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
783 (ring-ref comint-input-ring (if comint-input-ring-index |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
784 (mod (+ arg comint-input-ring-index) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
785 (ring-length comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
786 arg))) |
114 | 787 |
788 (defun comint-previous-input (arg) | |
789 "Cycle backwards through input history." | |
790 (interactive "*p") | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
791 (comint-previous-matching-input "." arg)) |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
792 |
114 | 793 (defun comint-next-input (arg) |
794 "Cycle forwards through input history." | |
795 (interactive "*p") | |
796 (comint-previous-input (- arg))) | |
797 | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
798 (defun comint-previous-matching-input-string (regexp arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
799 "Return the string matching REGEXP ARG places along the input ring. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
800 Moves relative to `comint-input-ring-index'." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
801 (let* ((pos (comint-previous-matching-input-string-position regexp arg))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
802 (if pos (ring-ref comint-input-ring pos)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
803 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
804 (defun comint-previous-matching-input-string-position (regexp arg &optional start) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
805 "Return the index matching REGEXP ARG places along the input ring. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
806 Moves relative to START, or `comint-input-ring-index'." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
807 (if (or (not (ring-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
808 (ring-empty-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
809 (error "No history")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
810 (let* ((len (ring-length comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
811 (motion (if (> arg 0) 1 -1)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
812 (n (mod (- (or start (comint-search-start arg)) motion) len)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
813 (tried-each-ring-item nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
814 (prev nil)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
815 ;; Do the whole search as many times as the argument says. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
816 (while (and (/= arg 0) (not tried-each-ring-item)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
817 ;; Step once. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
818 (setq prev n |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
819 n (mod (+ n motion) len)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
820 ;; If we haven't reached a match, step some more. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
821 (while (and (< n len) (not tried-each-ring-item) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
822 (not (string-match regexp (ring-ref comint-input-ring n)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
823 (setq n (mod (+ n motion) len) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
824 ;; If we have gone all the way around in this search. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
825 tried-each-ring-item (= n prev))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
826 (setq arg (if (> arg 0) (1- arg) (1+ arg)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
827 ;; Now that we know which ring element to use, if we found it, return that. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
828 (if (string-match regexp (ring-ref comint-input-ring n)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
829 n))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
830 |
2673
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
831 (defun comint-previous-matching-input (regexp arg) |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
832 "Search backwards through input history for match for REGEXP. |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
833 \(Previous history elements are earlier commands.) |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
834 With prefix argument N, search for Nth previous match. |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
835 If N is negative, find the next or Nth next match." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
836 (interactive (comint-regexp-arg "Previous input matching (regexp): ")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
837 (setq arg (comint-search-arg arg)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
838 (let ((pos (comint-previous-matching-input-string-position regexp arg))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
839 ;; Has a match been found? |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
840 (if (null pos) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
841 (error "Not found") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
842 (setq comint-input-ring-index pos) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
843 (message "History item: %d" (1+ pos)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
844 (delete-region |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
845 ;; Can't use kill-region as it sets this-command |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
846 (process-mark (get-buffer-process (current-buffer))) (point)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
847 (insert (ring-ref comint-input-ring pos))))) |
584 | 848 |
2673
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
849 (defun comint-next-matching-input (regexp arg) |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
850 "Search forwards through input history for match for REGEXP. |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
851 \(Later history elements are more recent commands.) |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
852 With prefix argument N, search for Nth following match. |
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
853 If N is negative, find the previous or Nth previous match." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
854 (interactive (comint-regexp-arg "Next input matching (regexp): ")) |
2673
27dd7479b158
(comint-previous-matching-input): New command, on M-r.
Richard M. Stallman <rms@gnu.org>
parents:
2627
diff
changeset
|
855 (comint-previous-matching-input regexp (- arg))) |
584 | 856 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
857 (defun comint-previous-matching-input-from-input (arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
858 "Search backwards through input history for match for current input. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
859 \(Previous history elements are earlier commands.) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
860 With prefix argument N, search for Nth previous match. |
5323
44a59f6e114e
(comint-next-matching-input-from-input): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5284
diff
changeset
|
861 If N is negative, search forwards for the -Nth following match." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
862 (interactive "p") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
863 (if (not (memq last-command '(comint-previous-matching-input-from-input |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
864 comint-next-matching-input-from-input))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
865 ;; Starting a new search |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
866 (setq comint-matching-input-from-input-string |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
867 (buffer-substring |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
868 (process-mark (get-buffer-process (current-buffer))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
869 (point)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
870 comint-input-ring-index nil)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
871 (comint-previous-matching-input |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
872 (concat "^" (regexp-quote comint-matching-input-from-input-string)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
873 arg)) |
584 | 874 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
875 (defun comint-next-matching-input-from-input (arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
876 "Search forwards through input history for match for current input. |
5323
44a59f6e114e
(comint-next-matching-input-from-input): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5284
diff
changeset
|
877 \(Following history elements are more recent commands.) |
44a59f6e114e
(comint-next-matching-input-from-input): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5284
diff
changeset
|
878 With prefix argument N, search for Nth following match. |
44a59f6e114e
(comint-next-matching-input-from-input): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5284
diff
changeset
|
879 If N is negative, search backwards for the -Nth previous match." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
880 (interactive "p") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
881 (comint-previous-matching-input-from-input (- arg))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
882 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
883 |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
884 (defun comint-replace-by-expanded-history (&optional silent) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
885 "Expand input command history references before point. |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
886 Expansion is dependent on the value of `comint-input-autoexpand'. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
887 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
888 This function depends on the buffer's idea of the input history, which may not |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
889 match the command interpreter's idea, assuming it has one. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
890 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
891 Assumes history syntax is like typical Un*x shells'. However, since emacs |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
892 cannot know the interpreter's idea of input line numbers, assuming it has one, |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
893 it cannot expand absolute input line number references. |
584 | 894 |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
895 If the optional argument SILENT is non-nil, never complain |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
896 even if history reference seems erroneous. |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
897 |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
898 See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
899 |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
900 Returns t if successful." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
901 (interactive) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
902 (if (and comint-input-autoexpand |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
903 (string-match "!\\|^\\^" (funcall comint-get-old-input)) |
6958
6962dec6fe55
(comint-replace-by-expanded-history): Expand only at prompt.
Karl Heuer <kwzh@gnu.org>
parents:
6890
diff
changeset
|
904 (save-excursion (beginning-of-line) |
6962dec6fe55
(comint-replace-by-expanded-history): Expand only at prompt.
Karl Heuer <kwzh@gnu.org>
parents:
6890
diff
changeset
|
905 (looking-at comint-prompt-regexp))) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
906 ;; Looks like there might be history references in the command. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
907 (let ((previous-modified-tick (buffer-modified-tick))) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
908 (message "Expanding history references...") |
6958
6962dec6fe55
(comint-replace-by-expanded-history): Expand only at prompt.
Karl Heuer <kwzh@gnu.org>
parents:
6890
diff
changeset
|
909 (comint-replace-by-expanded-history-before-point silent) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
910 (/= previous-modified-tick (buffer-modified-tick))))) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
911 |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
912 |
6958
6962dec6fe55
(comint-replace-by-expanded-history): Expand only at prompt.
Karl Heuer <kwzh@gnu.org>
parents:
6890
diff
changeset
|
913 (defun comint-replace-by-expanded-history-before-point (silent) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
914 "Expand directory stack reference before point. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
915 See `comint-replace-by-expanded-history'. Returns t if successful." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
916 (save-excursion |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
917 (let ((toend (- (save-excursion (end-of-line nil) (point)) (point))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
918 (start (progn (comint-bol nil) (point)))) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
919 (while (progn |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
920 (skip-chars-forward "^!^" |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
921 (save-excursion |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
922 (end-of-line nil) (- (point) toend))) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
923 (< (point) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
924 (save-excursion |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
925 (end-of-line nil) (- (point) toend)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
926 ;; This seems a bit complex. We look for references such as !!, !-num, |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
927 ;; !foo, !?foo, !{bar}, !?{bar}, ^oh, ^my^, ^god^it, ^never^ends^. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
928 ;; If that wasn't enough, the plings can be suffixed with argument |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
929 ;; range specifiers. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
930 ;; Argument ranges are complex too, so we hive off the input line, |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
931 ;; referenced with plings, with the range string to `comint-args'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
932 (setq comint-input-ring-index nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
933 (cond ((or (= (preceding-char) ?\\) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
934 (comint-within-quotes start (point))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
935 ;; The history is quoted, or we're in quotes. |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
936 (goto-char (1+ (point)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
937 ((looking-at "![0-9]+\\($\\|[^-]\\)") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
938 ;; We cannot know the interpreter's idea of input line numbers. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
939 (goto-char (match-end 0)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
940 (message "Absolute reference cannot be expanded")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
941 ((looking-at "!-\\([0-9]+\\)\\(:?[0-9^$*-]+\\)?") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
942 ;; Just a number of args from `number' lines backward. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
943 (let ((number (1- (string-to-number |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
944 (buffer-substring (match-beginning 1) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
945 (match-end 1)))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
946 (if (<= number (ring-length comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
947 (progn |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
948 (replace-match |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
949 (comint-args (comint-previous-input-string number) |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
950 (match-beginning 2) (match-end 2)) |
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
951 t t) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
952 (setq comint-input-ring-index number) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
953 (message "History item: %d" (1+ number))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
954 (goto-char (match-end 0)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
955 (message "Relative reference exceeds input history size")))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
956 ((or (looking-at "!!?:?\\([0-9^$*-]+\\)") (looking-at "!!")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
957 ;; Just a number of args from the previous input line. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
958 (replace-match |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
959 (comint-args (comint-previous-input-string 0) |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
960 (match-beginning 1) (match-end 1)) |
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
961 t t) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
962 (message "History item: previous")) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
963 ((looking-at |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
964 "!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\)\\(:?[0-9^$*-]+\\)?") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
965 ;; Most recent input starting with or containing (possibly |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
966 ;; protected) string, maybe just a number of args. Phew. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
967 (let* ((mb1 (match-beginning 1)) (me1 (match-end 1)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
968 (mb2 (match-beginning 2)) (me2 (match-end 2)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
969 (exp (buffer-substring (or mb2 mb1) (or me2 me1))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
970 (pref (if (save-match-data (looking-at "!\\?")) "" "^")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
971 (pos (save-match-data |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
972 (comint-previous-matching-input-string-position |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
973 (concat pref (regexp-quote exp)) 1)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
974 (if (null pos) |
6886
d4010211153e
(comint-replace-by-expanded-history-before-point): Advance point
Karl Heuer <kwzh@gnu.org>
parents:
6847
diff
changeset
|
975 (progn |
d4010211153e
(comint-replace-by-expanded-history-before-point): Advance point
Karl Heuer <kwzh@gnu.org>
parents:
6847
diff
changeset
|
976 (goto-char (match-end 0)) |
d4010211153e
(comint-replace-by-expanded-history-before-point): Advance point
Karl Heuer <kwzh@gnu.org>
parents:
6847
diff
changeset
|
977 (or silent |
d4010211153e
(comint-replace-by-expanded-history-before-point): Advance point
Karl Heuer <kwzh@gnu.org>
parents:
6847
diff
changeset
|
978 (progn (message "Not found") |
d4010211153e
(comint-replace-by-expanded-history-before-point): Advance point
Karl Heuer <kwzh@gnu.org>
parents:
6847
diff
changeset
|
979 (ding)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
980 (setq comint-input-ring-index pos) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
981 (replace-match |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
982 (comint-args (ring-ref comint-input-ring pos) |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
983 (match-beginning 4) (match-end 4)) |
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
984 t t) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
985 (message "History item: %d" (1+ pos))))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
986 ((looking-at "\\^\\([^^]+\\)\\^?\\([^^]*\\)\\^?") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
987 ;; Quick substitution on the previous input line. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
988 (let ((old (buffer-substring (match-beginning 1) (match-end 1))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
989 (new (buffer-substring (match-beginning 2) (match-end 2))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
990 (pos nil)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
991 (replace-match (comint-previous-input-string 0) t t) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
992 (setq pos (point)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
993 (goto-char (match-beginning 0)) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
994 (if (not (search-forward old pos t)) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
995 (or silent |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
996 (error "Not found")) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
997 (replace-match new t t) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
998 (message "History item: substituted")))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
999 (t |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1000 (goto-char (match-end 0)))))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1001 |
114 | 1002 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1003 (defun comint-magic-space (arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1004 "Expand input history references before point and insert ARG spaces. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1005 A useful command to bind to SPC. See `comint-replace-by-expanded-history'." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1006 (interactive "p") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1007 (comint-replace-by-expanded-history) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1008 (self-insert-command arg)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1009 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1010 (defun comint-within-quotes (beg end) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1011 "Return t if the number of quotes between BEG and END is odd. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1012 Quotes are single and double." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1013 (let ((countsq (comint-how-many-region "\\(^\\|[^\\\\]\\)\'" beg end)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1014 (countdq (comint-how-many-region "\\(^\\|[^\\\\]\\)\"" beg end))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1015 (or (= (mod countsq 2) 1) (= (mod countdq 2) 1)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1016 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1017 (defun comint-how-many-region (regexp beg end) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1018 "Return number of matches for REGEXP from BEG to END." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1019 (let ((count 0)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1020 (save-excursion |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1021 (save-match-data |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1022 (goto-char beg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1023 (while (re-search-forward regexp end t) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1024 (setq count (1+ count))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1025 count)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1026 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1027 (defun comint-args (string begin end) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1028 ;; From STRING, return the args depending on the range specified in the text |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1029 ;; from BEGIN to END. If BEGIN is nil, assume all args. Ignore leading `:'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1030 ;; Range can be x-y, x-, -y, where x/y can be [0-9], *, ^, $. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1031 (save-match-data |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1032 (if (null begin) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1033 (comint-arguments string 0 nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1034 (let* ((range (buffer-substring |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1035 (if (eq (char-after begin) ?:) (1+ begin) begin) end)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1036 (nth (cond ((string-match "^[*^]" range) 1) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1037 ((string-match "^-" range) 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1038 ((string-equal range "$") nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1039 (t (string-to-number range)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1040 (mth (cond ((string-match "[-*$]$" range) nil) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1041 ((string-match "-" range) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1042 (string-to-number (substring range (match-end 0)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1043 (t nth)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1044 (comint-arguments string nth mth))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1045 |
6154
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1046 ;; Return a list of arguments from ARG. Break it up at the |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1047 ;; delimiters in comint-delimiter-argument-list. Returned list is backwards. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1048 (defun comint-delim-arg (arg) |
6154
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1049 (if (null comint-delimiter-argument-list) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1050 (list arg) |
6154
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1051 (let ((args nil) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1052 (pos 0) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1053 (len (length arg))) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1054 (while (< pos len) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1055 (let ((char (aref arg pos)) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1056 (start pos)) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1057 (if (memq char comint-delimiter-argument-list) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1058 (while (and (< pos len) (eq (aref arg pos) char)) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1059 (setq pos (1+ pos))) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1060 (while (and (< pos len) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1061 (not (memq (aref arg pos) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1062 comint-delimiter-argument-list))) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1063 (setq pos (1+ pos)))) |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1064 (setq args (cons (substring arg start pos) args)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1065 args))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1066 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1067 (defun comint-arguments (string nth mth) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1068 "Return from STRING the NTH to MTH arguments. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1069 NTH and/or MTH can be nil, which means the last argument. |
6154
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1070 Returned arguments are separated by single spaces. |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1071 We assume whitespace separates arguments, except within quotes. |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1072 Also, a run of one or more of a single character |
385d5fe1c95c
(comint-arguments): Use just one regexp to find end of arg
Richard M. Stallman <rms@gnu.org>
parents:
6148
diff
changeset
|
1073 in `comint-delimiter-argument-list' is a separate argument. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1074 Argument 0 is the command name." |
8641
f84dbccdff87
(comint-arguments): Treat \n and \t like space.
Richard M. Stallman <rms@gnu.org>
parents:
8616
diff
changeset
|
1075 (let ((argpart "[^ \n\t\"'`]+\\|\\(\"[^\"]*\"\\|'[^']*'\\|`[^`]*`\\)") |
8616
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1076 (args ()) (pos 0) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1077 (count 0) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1078 beg str value quotes) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1079 ;; Build a list of all the args until we have as many as we want. |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1080 (while (and (or (null mth) (<= count mth)) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1081 (string-match argpart string pos)) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1082 (if (and beg (= pos (match-beginning 0))) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1083 ;; It's contiguous, part of the same arg. |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1084 (setq pos (match-end 0) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1085 quotes (or quotes (match-beginning 1))) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1086 ;; It's a new separate arg. |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1087 (if beg |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1088 ;; Put the previous arg, if there was one, onto ARGS. |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1089 (setq str (substring string beg pos) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1090 args (if quotes (cons str args) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1091 (nconc (comint-delim-arg str) args)) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1092 count (1+ count))) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1093 (setq quotes (match-beginning 1)) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1094 (setq beg (match-beginning 0)) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1095 (setq pos (match-end 0)))) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1096 (if beg |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1097 (setq str (substring string beg pos) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1098 args (if quotes (cons str args) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1099 (nconc (comint-delim-arg str) args)) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1100 count (1+ count))) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1101 (let ((n (or nth (1- count))) |
b9a9389714e1
(comint-arguments): Rewrite for speed.
Richard M. Stallman <rms@gnu.org>
parents:
8400
diff
changeset
|
1102 (m (if mth (1- (- count mth)) 0))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1103 (mapconcat |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1104 (function (lambda (a) a)) (nthcdr n (nreverse (nthcdr m args))) " ")))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1105 |
14169 | 1106 ;; |
1107 ;; Input processing stuff | |
1108 ;; | |
584 | 1109 |
1110 (defun comint-send-input () | |
1356 | 1111 "Send input to process. |
1112 After the process output mark, sends all text from the process mark to | |
1113 point as input to the process. Before the process output mark, calls value | |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
1114 of variable `comint-get-old-input' to retrieve old input, copies it to the |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1115 process mark, and sends it. If variable `comint-process-echoes' is nil, |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
1116 a terminal newline is also inserted into the buffer and sent to the process |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1117 \(if it is non-nil, all text from the process mark to point is deleted, |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1118 since it is assumed the remote process will re-echo it). |
114 | 1119 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1120 Any history reference may be expanded depending on the value of the variable |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1121 `comint-input-autoexpand'. The list of function names contained in the value |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
1122 of `comint-input-filter-functions' is called on the input before sending it. |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1123 The input is entered into the input history ring, if the value of variable |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1124 `comint-input-filter' returns non-nil when called on the input. |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1125 |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1126 If variable `comint-eol-on-send' is non-nil, then point is moved to the |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
1127 end of line before sending the input. |
114 | 1128 |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
1129 The values of `comint-get-old-input', `comint-input-filter-functions', and |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1130 `comint-input-filter' are chosen according to the command interpreter running |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1131 in the buffer. E.g., |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1132 |
114 | 1133 If the interpreter is the csh, |
584 | 1134 comint-get-old-input is the default: take the current line, discard any |
1135 initial string matching regexp comint-prompt-regexp. | |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
1136 comint-input-filter-functions monitors input for \"cd\", \"pushd\", and |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1137 \"popd\" commands. When it sees one, it cd's the buffer. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1138 comint-input-filter is the default: returns t if the input isn't all white |
584 | 1139 space. |
114 | 1140 |
1141 If the comint is Lucid Common Lisp, | |
584 | 1142 comint-get-old-input snarfs the sexp ending at point. |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
1143 comint-input-filter-functions does nothing. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1144 comint-input-filter returns nil if the input matches input-filter-regexp, |
114 | 1145 which matches (1) all whitespace (2) :a, :c, etc. |
1146 | |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
1147 Similarly for Soar, Scheme, etc." |
114 | 1148 (interactive) |
1149 ;; Note that the input string does not include its terminal newline. | |
584 | 1150 (let ((proc (get-buffer-process (current-buffer)))) |
1151 (if (not proc) (error "Current buffer has no process") | |
1152 (let* ((pmark (process-mark proc)) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1153 (intxt (if (>= (point) (marker-position pmark)) |
584 | 1154 (progn (if comint-eol-on-send (end-of-line)) |
1155 (buffer-substring pmark (point))) | |
705 | 1156 (let ((copy (funcall comint-get-old-input))) |
1157 (goto-char pmark) | |
1158 (insert copy) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1159 copy))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1160 (input (if (not (eq comint-input-autoexpand 'input)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1161 ;; Just whatever's already there |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1162 intxt |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1163 ;; Expand and leave it visible in buffer |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1164 (comint-replace-by-expanded-history t) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1165 (buffer-substring pmark (point)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1166 (history (if (not (eq comint-input-autoexpand 'history)) |
5166
7e66b092f331
(comint-send-input): Don't call comint-arguments
Richard M. Stallman <rms@gnu.org>
parents:
5152
diff
changeset
|
1167 input |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1168 ;; This is messy 'cos ultimately the original |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1169 ;; functions used do insertion, rather than return |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1170 ;; strings. We have to expand, then insert back. |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1171 (comint-replace-by-expanded-history t) |
5166
7e66b092f331
(comint-send-input): Don't call comint-arguments
Richard M. Stallman <rms@gnu.org>
parents:
5152
diff
changeset
|
1172 (let ((copy (buffer-substring pmark (point)))) |
7e66b092f331
(comint-send-input): Don't call comint-arguments
Richard M. Stallman <rms@gnu.org>
parents:
5152
diff
changeset
|
1173 (delete-region pmark (point)) |
15541
09b145e9bf4d
(comint-send-input): Use insert-before-markers for all the insertions.
Richard M. Stallman <rms@gnu.org>
parents:
15369
diff
changeset
|
1174 (insert-before-markers input) |
5166
7e66b092f331
(comint-send-input): Don't call comint-arguments
Richard M. Stallman <rms@gnu.org>
parents:
5152
diff
changeset
|
1175 copy)))) |
2539
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
1176 (if comint-process-echoes |
577c77cfd199
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
2518
diff
changeset
|
1177 (delete-region pmark (point)) |
15541
09b145e9bf4d
(comint-send-input): Use insert-before-markers for all the insertions.
Richard M. Stallman <rms@gnu.org>
parents:
15369
diff
changeset
|
1178 (insert-before-markers ?\n)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1179 (if (and (funcall comint-input-filter history) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1180 (or (null comint-input-ignoredups) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1181 (not (ring-p comint-input-ring)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1182 (ring-empty-p comint-input-ring) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1183 (not (string-equal (ring-ref comint-input-ring 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1184 history)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1185 (ring-insert comint-input-ring history)) |
12208
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
1186 (run-hook-with-args 'comint-input-filter-functions |
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
1187 (concat input "\n")) |
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
870
diff
changeset
|
1188 (setq comint-input-ring-index nil) |
8060
5b9bbe66631c
(comint-send-input): Update markers before actually sending the input.
Richard M. Stallman <rms@gnu.org>
parents:
8032
diff
changeset
|
1189 ;; Update the markers before we send the input |
5b9bbe66631c
(comint-send-input): Update markers before actually sending the input.
Richard M. Stallman <rms@gnu.org>
parents:
8032
diff
changeset
|
1190 ;; in case we get output amidst sending the input. |
705 | 1191 (set-marker comint-last-input-start pmark) |
1192 (set-marker comint-last-input-end (point)) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1193 (set-marker (process-mark proc) (point)) |
8060
5b9bbe66631c
(comint-send-input): Update markers before actually sending the input.
Richard M. Stallman <rms@gnu.org>
parents:
8032
diff
changeset
|
1194 (funcall comint-input-sender proc input) |
16546
06f92ef2857c
(comint-output-filter): Run comint-output-filter-functions
Richard M. Stallman <rms@gnu.org>
parents:
16409
diff
changeset
|
1195 ;; This used to call comint-output-filter-functions, |
06f92ef2857c
(comint-output-filter): Run comint-output-filter-functions
Richard M. Stallman <rms@gnu.org>
parents:
16409
diff
changeset
|
1196 ;; but that scrolled the buffer in undesirable ways. |
06f92ef2857c
(comint-output-filter): Run comint-output-filter-functions
Richard M. Stallman <rms@gnu.org>
parents:
16409
diff
changeset
|
1197 (run-hook-with-args 'comint-output-filter-functions ""))))) |
114 | 1198 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1199 ;; The purpose of using this filter for comint processes |
2683
21ab70613c42
(comint-filter): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2680
diff
changeset
|
1200 ;; is to keep comint-last-input-end from moving forward |
21ab70613c42
(comint-filter): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2680
diff
changeset
|
1201 ;; when output is inserted. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1202 (defun comint-output-filter (process string) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1203 ;; First check for killed buffer |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1204 (let ((oprocbuf (process-buffer process))) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1205 (if (and oprocbuf (buffer-name oprocbuf)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1206 (let ((obuf (current-buffer)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1207 (opoint nil) (obeg nil) (oend nil)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1208 (set-buffer oprocbuf) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1209 (setq opoint (point)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1210 (setq obeg (point-min)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1211 (setq oend (point-max)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1212 (let ((buffer-read-only nil) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1213 (nchars (length string)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1214 (ostart nil)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1215 (widen) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1216 (goto-char (process-mark process)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1217 (setq ostart (point)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1218 (if (<= (point) opoint) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1219 (setq opoint (+ opoint nchars))) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1220 ;; Insert after old_begv, but before old_zv. |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1221 (if (< (point) obeg) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1222 (setq obeg (+ obeg nchars))) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1223 (if (<= (point) oend) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1224 (setq oend (+ oend nchars))) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1225 (insert-before-markers string) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1226 ;; Don't insert initial prompt outside the top of the window. |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1227 (if (= (window-start (selected-window)) (point)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1228 (set-window-start (selected-window) (- (point) (length string)))) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1229 (if (and comint-last-input-end |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1230 (marker-buffer comint-last-input-end) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1231 (= (point) comint-last-input-end)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1232 (set-marker comint-last-input-end (- comint-last-input-end nchars))) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1233 (set-marker comint-last-output-start ostart) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1234 (set-marker (process-mark process) (point)) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1235 (force-mode-line-update)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1236 |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1237 (narrow-to-region obeg oend) |
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1238 (goto-char opoint) |
12208
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
1239 (run-hook-with-args 'comint-output-filter-functions string) |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1240 (set-buffer obuf))))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1241 |
4890
dab300dfe449
(comint-scroll-to-bottom-on-input): Default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4880
diff
changeset
|
1242 (defun comint-preinput-scroll-to-bottom () |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1243 "Go to the end of buffer in all windows showing it. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1244 Movement occurs if point in the selected window is not after the process mark, |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1245 and `this-command' is an insertion command. Insertion commands recognised |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1246 are `self-insert-command', `comint-magic-space', `yank', and `hilit-yank'. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1247 Depends on the value of `comint-scroll-to-bottom-on-input'. |
2683
21ab70613c42
(comint-filter): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2680
diff
changeset
|
1248 |
4890
dab300dfe449
(comint-scroll-to-bottom-on-input): Default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4880
diff
changeset
|
1249 This function should be a pre-command hook." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1250 (if (and comint-scroll-to-bottom-on-input |
4939
d9ad390ef4e3
(comint-preinput-scroll-to-bottom): Added
Richard M. Stallman <rms@gnu.org>
parents:
4928
diff
changeset
|
1251 (memq this-command '(self-insert-command comint-magic-space yank |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1252 hilit-yank))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1253 (let* ((selected (selected-window)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1254 (current (current-buffer)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1255 (process (get-buffer-process current)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1256 (scroll comint-scroll-to-bottom-on-input)) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1257 (if (and process (< (point) (process-mark process))) |
5122
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1258 (if (eq scroll 'this) |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1259 (goto-char (point-max)) |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1260 (walk-windows |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1261 (function (lambda (window) |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1262 (if (and (eq (window-buffer window) current) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1263 (or (eq scroll t) (eq scroll 'all))) |
5122
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1264 (progn |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1265 (select-window window) |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1266 (goto-char (point-max)) |
23f6d57ced16
(comint-preinput-scroll-to-bottom): If SCROLL is `this',
Richard M. Stallman <rms@gnu.org>
parents:
5058
diff
changeset
|
1267 (select-window selected))))) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1268 nil t)))))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1269 |
4890
dab300dfe449
(comint-scroll-to-bottom-on-input): Default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
4880
diff
changeset
|
1270 (defun comint-postoutput-scroll-to-bottom (string) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1271 "Go to the end of buffer in all windows showing it. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1272 Does not scroll if the current line is the last line in the buffer. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1273 Depends on the value of `comint-scroll-to-bottom-on-output' and |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1274 `comint-scroll-show-maximum-output'. |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1275 |
6187
280d4a97da69
(comint-input-filter-functions)
Richard M. Stallman <rms@gnu.org>
parents:
6185
diff
changeset
|
1276 This function should be in the list `comint-output-filter-functions'." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1277 (let* ((selected (selected-window)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1278 (current (current-buffer)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1279 (process (get-buffer-process current)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1280 (scroll comint-scroll-to-bottom-on-output)) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1281 (unwind-protect |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1282 (if process |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1283 (walk-windows |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1284 (function (lambda (window) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1285 (if (eq (window-buffer window) current) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1286 (progn |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1287 (select-window window) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1288 (if (and (< (point) (process-mark process)) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1289 (or (eq scroll t) (eq scroll 'all) |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1290 ;; Maybe user wants point to jump to end. |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1291 (and (eq scroll 'this) (eq selected window)) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1292 (and (eq scroll 'others) (not (eq selected window))) |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1293 ;; If point was at the end, keep it at end. |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1294 (>= (point) comint-last-output-start))) |
5284
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1295 (goto-char (process-mark process))) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1296 ;; Optionally scroll so that the text |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1297 ;; ends at the bottom of the window. |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1298 (if (and comint-scroll-show-maximum-output |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1299 (>= (point) (process-mark process))) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1300 (save-excursion |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1301 (goto-char (point-max)) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1302 (recenter -1))) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1303 (select-window selected))))) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1304 nil t)) |
9c8749be37da
(comint-read-input-ring): New arg SILENT.
Richard M. Stallman <rms@gnu.org>
parents:
5166
diff
changeset
|
1305 (set-buffer current)))) |
2683
21ab70613c42
(comint-filter): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2680
diff
changeset
|
1306 |
10833
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1307 (defun comint-truncate-buffer (&optional string) |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1308 "Truncate the buffer to `comint-buffer-maximum-size'. |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1309 This function could be on `comint-output-filter-functions' or bound to a key." |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1310 (interactive) |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1311 (save-excursion |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1312 (goto-char (process-mark (get-buffer-process (current-buffer)))) |
10833
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1313 (forward-line (- comint-buffer-maximum-size)) |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1314 (beginning-of-line) |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1315 (delete-region (point-min) (point)))) |
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1316 |
9245
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1317 (defun comint-strip-ctrl-m (&optional string) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1318 "Strip trailing `^M' characters from the current output group. |
10833
77d7d3990300
Added comint-buffer-maximum-size and comint-truncate-buffer.
Simon Marshall <simon@gnu.org>
parents:
10830
diff
changeset
|
1319 This function could be on `comint-output-filter-functions' or bound to a key." |
9245
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1320 (interactive) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1321 (let ((pmark (process-mark (get-buffer-process (current-buffer))))) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1322 (save-excursion |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1323 (goto-char |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1324 (if (interactive-p) comint-last-input-end comint-last-output-start)) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1325 (while (re-search-forward "\r+$" pmark t) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1326 (replace-match "" t t))))) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1327 (defalias 'shell-strip-ctrl-m 'comint-strip-ctrl-m) |
b2440a22efc2
(comint-strip-ctrl-m): Renamed from shell-strip-crtl-m and moved here.
Richard M. Stallman <rms@gnu.org>
parents:
9067
diff
changeset
|
1328 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1329 (defun comint-show-maximum-output () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1330 "Put the end of the buffer at the bottom of the window." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1331 (interactive) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1332 (goto-char (point-max)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1333 (recenter -1)) |
2683
21ab70613c42
(comint-filter): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2680
diff
changeset
|
1334 |
114 | 1335 (defun comint-get-old-input-default () |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1336 "Default for `comint-get-old-input'. |
1356 | 1337 Take the current line, and discard any initial text matching |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1338 `comint-prompt-regexp'." |
114 | 1339 (save-excursion |
584 | 1340 (beginning-of-line) |
1341 (comint-skip-prompt) | |
1342 (let ((beg (point))) | |
1343 (end-of-line) | |
1344 (buffer-substring beg (point))))) | |
1345 | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1346 (defun comint-copy-old-input () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1347 "Insert after prompt old input at point as new input to be edited. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1348 Calls `comint-get-old-input' to get old input." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1349 (interactive) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1350 (let ((input (funcall comint-get-old-input)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1351 (process (get-buffer-process (current-buffer)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1352 (if (not process) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1353 (error "Current buffer has no process") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1354 (goto-char (process-mark process)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1355 (insert input)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1356 |
584 | 1357 (defun comint-skip-prompt () |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1358 "Skip past the text matching regexp `comint-prompt-regexp'. |
584 | 1359 If this takes us past the end of the current line, don't skip at all." |
1360 (let ((eol (save-excursion (end-of-line) (point)))) | |
1361 (if (and (looking-at comint-prompt-regexp) | |
1362 (<= (match-end 0) eol)) | |
1363 (goto-char (match-end 0))))) | |
1364 | |
1365 (defun comint-after-pmark-p () | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1366 "Return t if point is after the process output marker." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1367 (let ((pmark (process-mark (get-buffer-process (current-buffer))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1368 (<= (marker-position pmark) (point)))) |
584 | 1369 |
1370 (defun comint-simple-send (proc string) | |
1371 "Default function for sending to PROC input STRING. | |
1372 This just sends STRING plus a newline. To override this, | |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1373 set the hook `comint-input-sender'." |
584 | 1374 (comint-send-string proc string) |
1375 (comint-send-string proc "\n")) | |
114 | 1376 |
1377 (defun comint-bol (arg) | |
1378 "Goes to the beginning of line, then skips past the prompt, if any. | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1379 If prefix argument is given (\\[universal-argument]) the prompt is not skipped. |
114 | 1380 |
584 | 1381 The prompt skip is done by skipping text matching the regular expression |
8266 | 1382 `comint-prompt-regexp', a buffer local variable." |
114 | 1383 (interactive "P") |
1384 (beginning-of-line) | |
584 | 1385 (if (null arg) (comint-skip-prompt))) |
114 | 1386 |
14169 | 1387 ;; These three functions are for entering text you don't want echoed or |
1388 ;; saved -- typically passwords to ftp, telnet, or somesuch. | |
1389 ;; Just enter m-x send-invisible and type in your line, or add | |
1390 ;; `comint-watch-for-password-prompt' to `comint-output-filter-functions'. | |
584 | 1391 |
705 | 1392 (defun comint-read-noecho (prompt &optional stars) |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1393 "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
|
1394 Prompt with argument PROMPT, a string. Optional argument STARS causes |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1395 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
|
1396 RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. C-g aborts (if |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1397 `inhibit-quit' is set because e.g. this function was called from a process |
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1398 filter and C-g is pressed, this function returns nil rather than a string). |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1399 |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1400 Note that the keystrokes comprising the text can still be recovered |
16409
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1401 \(temporarily) with \\[view-lossage]. Some people find this worrysome. |
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1402 Once the caller uses the password, it can erase the password |
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1403 by doing (fillarray STRING 0)." |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1404 (let ((ans "") |
16409
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1405 (newans nil) |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1406 (c 0) |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1407 (echo-keystrokes 0) |
705 | 1408 (cursor-in-echo-area t) |
11156
31a046cedfc8
(comint-read-noecho): Don't log prompt messages.
Karl Heuer <kwzh@gnu.org>
parents:
11147
diff
changeset
|
1409 (message-log-max nil) |
31a046cedfc8
(comint-read-noecho): Don't log prompt messages.
Karl Heuer <kwzh@gnu.org>
parents:
11147
diff
changeset
|
1410 (done nil)) |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1411 (while (not done) |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1412 (if stars |
11147
8c896f45f888
(comint-read-noecho): Use a format string, in case
Karl Heuer <kwzh@gnu.org>
parents:
10833
diff
changeset
|
1413 (message "%s%s" prompt (make-string (length ans) ?*)) |
8c896f45f888
(comint-read-noecho): Use a format string, in case
Karl Heuer <kwzh@gnu.org>
parents:
10833
diff
changeset
|
1414 (message "%s" prompt)) |
9764
077430ee7179
(comint-read-noecho): Use `read-char-exclusive' instead of `read-char'.
Richard M. Stallman <rms@gnu.org>
parents:
9388
diff
changeset
|
1415 ;; Use this instead of `read-char' to avoid "Non-character input-event". |
077430ee7179
(comint-read-noecho): Use `read-char-exclusive' instead of `read-char'.
Richard M. Stallman <rms@gnu.org>
parents:
9388
diff
changeset
|
1416 (setq c (read-char-exclusive)) |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1417 (cond ((= c ?\C-g) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1418 ;; This function may get called from a process filter, where |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1419 ;; inhibit-quit is set. In later versions of emacs read-char |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1420 ;; may clear quit-flag itself and return C-g. That would make |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1421 ;; it impossible to quit this loop in a simple way, so |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1422 ;; re-enable it here (for backward-compatibility the check for |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1423 ;; quit-flag below would still be necessary, so this seems |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1424 ;; like the simplest way to do things). |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1425 (setq quit-flag t |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1426 done t)) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1427 ((or (= c ?\r) (= c ?\n) (= c ?\e)) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1428 (setq done t)) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1429 ((= c ?\C-u) |
16409
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1430 (fillarray ans 0) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1431 (setq ans "")) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1432 ((and (/= c ?\b) (/= c ?\177)) |
16409
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1433 (setq newans (concat ans (char-to-string c))) |
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1434 (fillarray ans 0) |
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1435 (setq ans newans)) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1436 ((> (length ans) 0) |
16409
258a28c21b74
(comint-read-noecho): Clear out the intermediate strings.
Richard M. Stallman <rms@gnu.org>
parents:
15817
diff
changeset
|
1437 (aset ans (1- (length ans)) 0) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1438 (setq ans (substring ans 0 -1))))) |
2455
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1439 (if quit-flag |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1440 ;; 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
|
1441 (prog1 |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1442 (setq quit-flag nil) |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1443 (message "Quit") |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1444 (beep t)) |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1445 (message "") |
27d28402ee59
new comint-read-noecho.
Noah Friedman <friedman@splode.com>
parents:
2307
diff
changeset
|
1446 ans))) |
705 | 1447 |
114 | 1448 (defun send-invisible (str) |
1356 | 1449 "Read a string without echoing. |
13702
f7bf7f756503
Use comint-input-sender to send text (Peter Gabriel <gabriel@or.iabg.de>).
Simon Marshall <simon@gnu.org>
parents:
13271
diff
changeset
|
1450 Then send it to the process running in the current buffer. |
f7bf7f756503
Use comint-input-sender to send text (Peter Gabriel <gabriel@or.iabg.de>).
Simon Marshall <simon@gnu.org>
parents:
13271
diff
changeset
|
1451 The string is sent using `comint-input-sender'. |
584 | 1452 Security bug: your string can still be temporarily recovered with |
1453 \\[view-lossage]." | |
15727 | 1454 (interactive "P") ; Defeat snooping via C-x ESC ESC |
114 | 1455 (let ((proc (get-buffer-process (current-buffer)))) |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1456 (if (not proc) |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1457 (error "Current buffer has no process") |
13702
f7bf7f756503
Use comint-input-sender to send text (Peter Gabriel <gabriel@or.iabg.de>).
Simon Marshall <simon@gnu.org>
parents:
13271
diff
changeset
|
1458 (funcall comint-input-sender proc |
f7bf7f756503
Use comint-input-sender to send text (Peter Gabriel <gabriel@or.iabg.de>).
Simon Marshall <simon@gnu.org>
parents:
13271
diff
changeset
|
1459 (if (stringp str) str (comint-read-noecho "Non-echoed text: " t)))))) |
114 | 1460 |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1461 (defun comint-watch-for-password-prompt (string) |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1462 "Prompt in the minibuffer for password and send without echoing. |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1463 This function uses `send-invisible' to read and send a password to the buffer's |
8087
c22d7c5168f5
comint-password-prompt-regexp: New variable.
Noah Friedman <friedman@splode.com>
parents:
8060
diff
changeset
|
1464 process if STRING contains a password prompt defined by |
c22d7c5168f5
comint-password-prompt-regexp: New variable.
Noah Friedman <friedman@splode.com>
parents:
8060
diff
changeset
|
1465 `comint-password-prompt-regexp'. |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1466 |
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1467 This function could be in the list `comint-output-filter-functions'." |
8087
c22d7c5168f5
comint-password-prompt-regexp: New variable.
Noah Friedman <friedman@splode.com>
parents:
8060
diff
changeset
|
1468 (if (string-match comint-password-prompt-regexp string) |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1469 (send-invisible nil))) |
114 | 1470 |
14169 | 1471 ;; Low-level process communication |
114 | 1472 |
9067
e3c21008877f
(comint-input-chunk-size): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
8641
diff
changeset
|
1473 (defalias 'comint-send-string 'process-send-string) |
e3c21008877f
(comint-input-chunk-size): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
8641
diff
changeset
|
1474 (defalias 'comint-send-region 'process-send-region) |
114 | 1475 |
14169 | 1476 ;; Random input hackage |
114 | 1477 |
584 | 1478 (defun comint-kill-output () |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1479 "Kill all output from interpreter since last input. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1480 Does not delete the prompt." |
114 | 1481 (interactive) |
6998
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1482 (let ((proc (get-buffer-process (current-buffer))) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1483 (replacement nil)) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1484 (save-excursion |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1485 (let ((pmark (progn (goto-char (process-mark proc)) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1486 (beginning-of-line nil) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1487 (point-marker)))) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1488 (delete-region comint-last-input-end pmark) |
12519
dd3560e3254c
(comint-kill-output): Preserve entire partial line at
Karl Heuer <kwzh@gnu.org>
parents:
12208
diff
changeset
|
1489 (goto-char (process-mark proc)) |
6998
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1490 (setq replacement (concat "*** output flushed ***\n" |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1491 (buffer-substring pmark (point)))) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1492 (delete-region pmark (point)))) |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1493 ;; Output message and put back prompt |
40163ff9fc7c
(comint-mode): Set comint-last-input-start and
Richard M. Stallman <rms@gnu.org>
parents:
6958
diff
changeset
|
1494 (comint-output-filter proc replacement))) |
114 | 1495 |
1496 (defun comint-show-output () | |
584 | 1497 "Display start of this batch of interpreter output at top of window. |
6507
ff41e0e932b8
(comint-run): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6256
diff
changeset
|
1498 Sets mark to the value of point when this command is run." |
114 | 1499 (interactive) |
5593
58c0f2c7dfae
(comint-show-output): Leave point at start of output, but push the mark.
Richard M. Stallman <rms@gnu.org>
parents:
5539
diff
changeset
|
1500 (push-mark) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1501 (let ((pos (point))) |
5476
155472377864
(comint-show-output): Use (point-max) rather than erring when the
Roland McGrath <roland@gnu.org>
parents:
5424
diff
changeset
|
1502 (goto-char (or (marker-position comint-last-input-end) (point-max))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1503 (beginning-of-line 0) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1504 (set-window-start (selected-window) (point)) |
5593
58c0f2c7dfae
(comint-show-output): Leave point at start of output, but push the mark.
Richard M. Stallman <rms@gnu.org>
parents:
5539
diff
changeset
|
1505 (comint-skip-prompt))) |
114 | 1506 |
1507 (defun comint-interrupt-subjob () | |
584 | 1508 "Interrupt the current subjob." |
114 | 1509 (interactive) |
584 | 1510 (interrupt-process nil comint-ptyp)) |
114 | 1511 |
1512 (defun comint-kill-subjob () | |
584 | 1513 "Send kill signal to the current subjob." |
114 | 1514 (interactive) |
584 | 1515 (kill-process nil comint-ptyp)) |
114 | 1516 |
1517 (defun comint-quit-subjob () | |
584 | 1518 "Send quit signal to the current subjob." |
114 | 1519 (interactive) |
584 | 1520 (quit-process nil comint-ptyp)) |
114 | 1521 |
1522 (defun comint-stop-subjob () | |
584 | 1523 "Stop the current subjob. |
114 | 1524 WARNING: if there is no current subjob, you can end up suspending |
584 | 1525 the top-level process running in the buffer. If you accidentally do |
1526 this, use \\[comint-continue-subjob] to resume the process. (This | |
1527 is not a problem with most shells, since they ignore this signal.)" | |
114 | 1528 (interactive) |
584 | 1529 (stop-process nil comint-ptyp)) |
114 | 1530 |
1531 (defun comint-continue-subjob () | |
584 | 1532 "Send CONT signal to process buffer's process group. |
114 | 1533 Useful if you accidentally suspend the top-level process." |
1534 (interactive) | |
584 | 1535 (continue-process nil comint-ptyp)) |
114 | 1536 |
1537 (defun comint-kill-input () | |
584 | 1538 "Kill all text from last stuff output by interpreter to point." |
114 | 1539 (interactive) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1540 (let ((pmark (process-mark (get-buffer-process (current-buffer))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1541 (if (> (point) (marker-position pmark)) |
584 | 1542 (kill-region pmark (point))))) |
114 | 1543 |
1544 (defun comint-delchar-or-maybe-eof (arg) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1545 "Delete ARG characters forward, or (if at eob) send an EOF to subprocess." |
114 | 1546 (interactive "p") |
1547 (if (eobp) | |
1548 (process-send-eof) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1549 (delete-char arg))) |
584 | 1550 |
4112
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1551 (defun comint-send-eof () |
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1552 "Send an EOF to the current buffer's process." |
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1553 (interactive) |
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1554 (process-send-eof)) |
584 | 1555 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1556 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1557 (defun comint-backward-matching-input (regexp arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1558 "Search backward through buffer for match for REGEXP. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1559 Matches are searched for on lines that match `comint-prompt-regexp'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1560 With prefix argument N, search for Nth previous match. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1561 If N is negative, find the next or Nth next match." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1562 (interactive (comint-regexp-arg "Backward input matching (regexp): ")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1563 (let* ((re (concat comint-prompt-regexp ".*" regexp)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1564 (pos (save-excursion (end-of-line (if (> arg 0) 0 1)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1565 (if (re-search-backward re nil t arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1566 (point))))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1567 (if (null pos) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1568 (progn (message "Not found") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1569 (ding)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1570 (goto-char pos) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1571 (comint-bol nil)))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1572 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1573 (defun comint-forward-matching-input (regexp arg) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1574 "Search forward through buffer for match for REGEXP. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1575 Matches are searched for on lines that match `comint-prompt-regexp'. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1576 With prefix argument N, search for Nth following match. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1577 If N is negative, find the previous or Nth previous match." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1578 (interactive (comint-regexp-arg "Forward input matching (regexp): ")) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1579 (comint-backward-matching-input regexp (- arg))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1580 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1581 |
4112
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1582 (defun comint-next-prompt (n) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1583 "Move to end of Nth next prompt in the buffer. |
4112
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1584 See `comint-prompt-regexp'." |
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1585 (interactive "p") |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1586 (let ((paragraph-start comint-prompt-regexp)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1587 (end-of-line (if (> n 0) 1 0)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1588 (forward-paragraph n) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1589 (comint-skip-prompt))) |
584 | 1590 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1591 (defun comint-previous-prompt (n) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1592 "Move to end of Nth previous prompt in the buffer. |
4112
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1593 See `comint-prompt-regexp'." |
ab7dee78e335
(comint-{next,prev}-prompt, comint-send-eof): New functions.
Roland McGrath <roland@gnu.org>
parents:
3985
diff
changeset
|
1594 (interactive "p") |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1595 (comint-next-prompt (- n))) |
114 | 1596 |
14169 | 1597 ;; Support for source-file processing commands. |
1598 ;;============================================================================ | |
1599 ;; Many command-interpreters (e.g., Lisp, Scheme, Soar) have | |
1600 ;; commands that process files of source text (e.g. loading or compiling | |
1601 ;; files). So the corresponding process-in-a-buffer modes have commands | |
1602 ;; for doing this (e.g., lisp-load-file). The functions below are useful | |
1603 ;; for defining these commands. | |
1604 ;; | |
1605 ;; Alas, these guys don't do exactly the right thing for Lisp, Scheme | |
1606 ;; and Soar, in that they don't know anything about file extensions. | |
1607 ;; So the compile/load interface gets the wrong default occasionally. | |
1608 ;; The load-file/compile-file default mechanism could be smarter -- it | |
1609 ;; doesn't know about the relationship between filename extensions and | |
1610 ;; whether the file is source or executable. If you compile foo.lisp | |
1611 ;; with compile-file, then the next load-file should use foo.bin for | |
1612 ;; the default, not foo.lisp. This is tricky to do right, particularly | |
1613 ;; because the extension for executable files varies so much (.o, .bin, | |
1614 ;; .lbin, .mo, .vo, .ao, ...). | |
114 | 1615 |
1616 | |
14169 | 1617 ;; COMINT-SOURCE-DEFAULT -- determines defaults for source-file processing |
1618 ;; commands. | |
1619 ;; | |
1620 ;; COMINT-CHECK-SOURCE -- if FNAME is in a modified buffer, asks you if you | |
1621 ;; want to save the buffer before issuing any process requests to the command | |
1622 ;; interpreter. | |
1623 ;; | |
1624 ;; COMINT-GET-SOURCE -- used by the source-file processing commands to prompt | |
1625 ;; for the file to process. | |
114 | 1626 |
14169 | 1627 ;; (COMINT-SOURCE-DEFAULT previous-dir/file source-modes) |
1628 ;;============================================================================ | |
1629 ;; This function computes the defaults for the load-file and compile-file | |
1630 ;; commands for tea, soar, cmulisp, and cmuscheme modes. | |
1631 ;; | |
1632 ;; - PREVIOUS-DIR/FILE is a pair (directory . filename) from the last | |
1633 ;; source-file processing command. NIL if there hasn't been one yet. | |
1634 ;; - SOURCE-MODES is a list used to determine what buffers contain source | |
1635 ;; files: if the major mode of the buffer is in SOURCE-MODES, it's source. | |
1636 ;; Typically, (lisp-mode) or (scheme-mode). | |
1637 ;; | |
1638 ;; If the command is given while the cursor is inside a string, *and* | |
1639 ;; the string is an existing filename, *and* the filename is not a directory, | |
1640 ;; then the string is taken as default. This allows you to just position | |
1641 ;; your cursor over a string that's a filename and have it taken as default. | |
1642 ;; | |
1643 ;; If the command is given in a file buffer whose major mode is in | |
1644 ;; SOURCE-MODES, then the the filename is the default file, and the | |
1645 ;; file's directory is the default directory. | |
1646 ;; | |
1647 ;; If the buffer isn't a source file buffer (e.g., it's the process buffer), | |
1648 ;; then the default directory & file are what was used in the last source-file | |
1649 ;; processing command (i.e., PREVIOUS-DIR/FILE). If this is the first time | |
1650 ;; the command has been run (PREVIOUS-DIR/FILE is nil), the default directory | |
1651 ;; is the cwd, with no default file. (\"no default file\" = nil) | |
1652 ;; | |
1653 ;; SOURCE-REGEXP is typically going to be something like (tea-mode) | |
1654 ;; for T programs, (lisp-mode) for Lisp programs, (soar-mode lisp-mode) | |
1655 ;; for Soar programs, etc. | |
1656 ;; | |
1657 ;; The function returns a pair: (default-directory . default-file). | |
114 | 1658 |
1659 (defun comint-source-default (previous-dir/file source-modes) | |
1660 (cond ((and buffer-file-name (memq major-mode source-modes)) | |
1661 (cons (file-name-directory buffer-file-name) | |
1662 (file-name-nondirectory buffer-file-name))) | |
1663 (previous-dir/file) | |
1664 (t | |
1665 (cons default-directory nil)))) | |
1666 | |
584 | 1667 |
14169 | 1668 ;; (COMINT-CHECK-SOURCE fname) |
1669 ;;============================================================================ | |
1670 ;; Prior to loading or compiling (or otherwise processing) a file (in the CMU | |
1671 ;; process-in-a-buffer modes), this function can be called on the filename. | |
1672 ;; If the file is loaded into a buffer, and the buffer is modified, the user | |
1673 ;; is queried to see if he wants to save the buffer before proceeding with | |
1674 ;; the load or compile. | |
114 | 1675 |
1676 (defun comint-check-source (fname) | |
1677 (let ((buff (get-file-buffer fname))) | |
1678 (if (and buff | |
1679 (buffer-modified-p buff) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1680 (y-or-n-p (format "Save buffer %s first? " (buffer-name buff)))) |
114 | 1681 ;; save BUFF. |
1682 (let ((old-buffer (current-buffer))) | |
1683 (set-buffer buff) | |
1684 (save-buffer) | |
1685 (set-buffer old-buffer))))) | |
1686 | |
584 | 1687 |
14169 | 1688 ;; (COMINT-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p) |
1689 ;;============================================================================ | |
1690 ;; COMINT-GET-SOURCE is used to prompt for filenames in command-interpreter | |
1691 ;; commands that process source files (like loading or compiling a file). | |
1692 ;; It prompts for the filename, provides a default, if there is one, | |
1693 ;; and returns the result filename. | |
1694 ;; | |
1695 ;; See COMINT-SOURCE-DEFAULT for more on determining defaults. | |
1696 ;; | |
1697 ;; PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair | |
1698 ;; from the last source processing command. SOURCE-MODES is a list of major | |
1699 ;; modes used to determine what file buffers contain source files. (These | |
1700 ;; two arguments are used for determining defaults). If MUSTMATCH-P is true, | |
1701 ;; then the filename reader will only accept a file that exists. | |
1702 ;; | |
1703 ;; A typical use: | |
1704 ;; (interactive (comint-get-source "Compile file: " prev-lisp-dir/file | |
1705 ;; '(lisp-mode) t)) | |
114 | 1706 |
14169 | 1707 ;; This is pretty stupid about strings. It decides we're in a string |
1708 ;; if there's a quote on both sides of point on the current line. | |
114 | 1709 (defun comint-extract-string () |
3386
bc4729d67e6e
(comint-filter): Put window-start before the input.
Richard M. Stallman <rms@gnu.org>
parents:
3113
diff
changeset
|
1710 "Return string around POINT that starts the current line, or nil." |
114 | 1711 (save-excursion |
1712 (let* ((point (point)) | |
1713 (bol (progn (beginning-of-line) (point))) | |
1714 (eol (progn (end-of-line) (point))) | |
1715 (start (progn (goto-char point) | |
1716 (and (search-backward "\"" bol t) | |
1717 (1+ (point))))) | |
1718 (end (progn (goto-char point) | |
1719 (and (search-forward "\"" eol t) | |
1720 (1- (point)))))) | |
1721 (and start end | |
1722 (buffer-substring start end))))) | |
1723 | |
1724 (defun comint-get-source (prompt prev-dir/file source-modes mustmatch-p) | |
1725 (let* ((def (comint-source-default prev-dir/file source-modes)) | |
1726 (stringfile (comint-extract-string)) | |
1727 (sfile-p (and stringfile | |
584 | 1728 (condition-case () |
1729 (file-exists-p stringfile) | |
1730 (error nil)) | |
114 | 1731 (not (file-directory-p stringfile)))) |
1732 (defdir (if sfile-p (file-name-directory stringfile) | |
1733 (car def))) | |
1734 (deffile (if sfile-p (file-name-nondirectory stringfile) | |
1735 (cdr def))) | |
1736 (ans (read-file-name (if deffile (format "%s(default %s) " | |
1737 prompt deffile) | |
1738 prompt) | |
1739 defdir | |
1740 (concat defdir deffile) | |
1741 mustmatch-p))) | |
1742 (list (expand-file-name (substitute-in-file-name ans))))) | |
1743 | |
14169 | 1744 ;; I am somewhat divided on this string-default feature. It seems |
1745 ;; to violate the principle-of-least-astonishment, in that it makes | |
1746 ;; the default harder to predict, so you actually have to look and see | |
1747 ;; what the default really is before choosing it. This can trip you up. | |
1748 ;; On the other hand, it can be useful, I guess. I would appreciate feedback | |
1749 ;; on this. | |
1750 ;; -Olin | |
584 | 1751 |
114 | 1752 |
14169 | 1753 ;; Simple process query facility. |
1754 ;; =========================================================================== | |
1755 ;; This function is for commands that want to send a query to the process | |
1756 ;; and show the response to the user. For example, a command to get the | |
1757 ;; arglist for a Common Lisp function might send a "(arglist 'foo)" query | |
1758 ;; to an inferior Common Lisp process. | |
1759 ;; | |
1760 ;; This simple facility just sends strings to the inferior process and pops | |
1761 ;; up a window for the process buffer so you can see what the process | |
1762 ;; responds with. We don't do anything fancy like try to intercept what the | |
1763 ;; process responds with and put it in a pop-up window or on the message | |
1764 ;; line. We just display the buffer. Low tech. Simple. Works good. | |
114 | 1765 |
14169 | 1766 ;; Send to the inferior process PROC the string STR. Pop-up but do not select |
1767 ;; a window for the inferior process so that its response can be seen. | |
114 | 1768 (defun comint-proc-query (proc str) |
1769 (let* ((proc-buf (process-buffer proc)) | |
1770 (proc-mark (process-mark proc))) | |
1771 (display-buffer proc-buf) | |
1772 (set-buffer proc-buf) ; but it's not the selected *window* | |
1773 (let ((proc-win (get-buffer-window proc-buf)) | |
1774 (proc-pt (marker-position proc-mark))) | |
1775 (comint-send-string proc str) ; send the query | |
1776 (accept-process-output proc) ; wait for some output | |
1777 ;; Try to position the proc window so you can see the answer. | |
1778 ;; This is bogus code. If you delete the (sit-for 0), it breaks. | |
1779 ;; I don't know why. Wizards invited to improve it. | |
1780 (if (not (pos-visible-in-window-p proc-pt proc-win)) | |
1781 (let ((opoint (window-point proc-win))) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1782 (set-window-point proc-win proc-mark) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1783 (sit-for 0) |
114 | 1784 (if (not (pos-visible-in-window-p opoint proc-win)) |
1785 (push-mark opoint) | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1786 (set-window-point proc-win opoint))))))) |
114 | 1787 |
1788 | |
14169 | 1789 ;; Filename/command/history completion in a buffer |
1790 ;; =========================================================================== | |
1791 ;; Useful completion functions, courtesy of the Ergo group. | |
114 | 1792 |
14169 | 1793 ;; Six commands: |
1794 ;; comint-dynamic-complete Complete or expand command, filename, | |
1795 ;; history at point. | |
1796 ;; comint-dynamic-complete-filename Complete filename at point. | |
1797 ;; comint-dynamic-list-filename-completions List completions in help buffer. | |
1798 ;; comint-replace-by-expanded-filename Expand and complete filename at point; | |
1799 ;; replace with expanded/completed name. | |
1800 ;; comint-dynamic-simple-complete Complete stub given candidates. | |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1801 |
14169 | 1802 ;; These are not installed in the comint-mode keymap. But they are |
1803 ;; available for people who want them. Shell-mode installs them: | |
1804 ;; (define-key shell-mode-map "\t" 'comint-dynamic-complete) | |
1805 ;; (define-key shell-mode-map "\M-?" | |
1806 ;; 'comint-dynamic-list-filename-completions))) | |
1807 ;; | |
1808 ;; Commands like this are fine things to put in load hooks if you | |
1809 ;; want them present in specific modes. | |
584 | 1810 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1811 (defvar comint-completion-autolist nil |
13971
49207f2e2130
(comint-ptyp, comint-completion-autolist): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13702
diff
changeset
|
1812 "*If non-nil, automatically list possibilities on partial completion. |
4923
63aed739d09d
(comint-postoutput-scroll-to-bottom):
Richard M. Stallman <rms@gnu.org>
parents:
4899
diff
changeset
|
1813 This mirrors the optional behavior of tcsh.") |
114 | 1814 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1815 (defvar comint-completion-addsuffix t |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1816 "*If non-nil, add a `/' to completed directories, ` ' to file names. |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1817 If a cons pair, it should be of the form (DIRSUFFIX . FILESUFFIX) where |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1818 DIRSUFFIX and FILESUFFIX are strings added on unambiguous or exact completion. |
4923
63aed739d09d
(comint-postoutput-scroll-to-bottom):
Richard M. Stallman <rms@gnu.org>
parents:
4899
diff
changeset
|
1819 This mirrors the optional behavior of tcsh.") |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1820 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1821 (defvar comint-completion-recexact nil |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1822 "*If non-nil, use shortest completion if characters cannot be added. |
4923
63aed739d09d
(comint-postoutput-scroll-to-bottom):
Richard M. Stallman <rms@gnu.org>
parents:
4899
diff
changeset
|
1823 This mirrors the optional behavior of tcsh. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1824 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1825 A non-nil value is useful if `comint-completion-autolist' is non-nil too.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1826 |
6256
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1827 (defvar comint-completion-fignore nil |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1828 "*List of suffixes to be disregarded during file completion. |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1829 This mirrors the optional behavior of bash and tcsh. |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1830 |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1831 Note that this applies to `comint-dynamic-complete-filename' only.") |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1832 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1833 (defvar comint-file-name-prefix "" |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1834 "Prefix prepended to absolute file names taken from process input. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1835 This is used by comint's and shell's completion functions, and by shell's |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1836 directory tracking functions.") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1837 |
15817
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
1838 (defvar comint-file-name-chars |
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
1839 (if (memq system-type '(ms-dos windows-nt)) |
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
1840 "~/A-Za-z0-9_^$!#%&{}@`'.()-" |
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
1841 "~/A-Za-z0-9+@:_.$#%,={}-") |
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
1842 "String of characters valid in a file name. |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1843 |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1844 This is a good thing to set in mode hooks.") |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1845 |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1846 (defvar comint-file-name-quote-list nil |
15361
c1ba0a32590d
(comint-file-name-quote-list): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
15337
diff
changeset
|
1847 "List of characters to quote with `\\' when in a file name. |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1848 |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1849 This is a good thing to set in mode hooks.") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1850 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1851 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1852 (defun comint-directory (directory) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1853 ;; Return expanded DIRECTORY, with `comint-file-name-prefix' if absolute. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1854 (expand-file-name (if (file-name-absolute-p directory) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1855 (concat comint-file-name-prefix directory) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1856 directory))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1857 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1858 |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1859 (defun comint-word (word-chars) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1860 "Return the word of WORD-CHARS at point, or nil if non is found. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1861 Word constituents are considered to be those in WORD-CHARS, which is like the |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1862 inside of a \"[...]\" (see `skip-chars-forward')." |
584 | 1863 (save-excursion |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1864 (let ((non-word-chars (concat "[^\\\\" word-chars "]")) (here (point))) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1865 (while (and (re-search-backward non-word-chars nil 'move) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1866 ;(memq (char-after (point)) shell-file-name-quote-list) |
12058
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1867 (eq (preceding-char) ?\\)) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1868 (backward-char 1)) |
12058
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1869 ;; Don't go forward over a word-char (this can happen if we're at bob). |
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1870 (if (or (not (bobp)) (looking-at non-word-chars)) |
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1871 (forward-char 1)) |
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1872 ;; Set match-data to match the entire string. |
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1873 (if (< (point) here) |
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1874 (progn (store-match-data (list (point) here)) |
24c19691068e
Don't go forward over a word-char if we're at bob, and set match-data.
Simon Marshall <simon@gnu.org>
parents:
11310
diff
changeset
|
1875 (match-string 0)))))) |
584 | 1876 |
15369
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1877 (defun comint-substitute-in-file-name (filename) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1878 "Return FILENAME with environment variables substituted. |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1879 Supports additional environment variable syntax of the command |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1880 interpreter (e.g., the percent notation of cmd.exe on NT)." |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1881 (let ((name (substitute-in-file-name filename))) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1882 (if (memq system-type '(ms-dos windows-nt)) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1883 (let (env-var-name |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1884 env-var-val) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1885 (save-match-data |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1886 (while (string-match "%\\([^\\\\/]*\\)%" name) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1887 (setq env-var-name |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1888 (substring name (match-beginning 1) (match-end 1))) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1889 (setq env-var-val (if (getenv env-var-name) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1890 (getenv env-var-name) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1891 "")) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1892 (setq name (replace-match env-var-val nil nil name)))))) |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1893 name)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1894 |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1895 (defun comint-match-partial-filename () |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1896 "Return the filename at point, or nil if non is found. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1897 Environment variables are substituted. See `comint-word'." |
15817
9e94b5fdaab1
(comint-file-name-chars): Was comint-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents:
15727
diff
changeset
|
1898 (let ((filename (comint-word comint-file-name-chars))) |
15369
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1899 (and filename (comint-substitute-in-file-name |
0c818ae83d43
(comint-dynamic-complete-as-filename)
Richard M. Stallman <rms@gnu.org>
parents:
15361
diff
changeset
|
1900 (comint-unquote-filename filename))))) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1901 |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1902 |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1903 (defun comint-quote-filename (filename) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1904 "Return FILENAME with magic characters quoted. |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1905 Magic characters are those in `comint-file-name-quote-list'." |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1906 (if (null comint-file-name-quote-list) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1907 filename |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1908 (let ((regexp |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1909 (format "\\(^\\|[^\\]\\)\\([%s]\\)" |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1910 (mapconcat 'char-to-string comint-file-name-quote-list "")))) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1911 (save-match-data |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1912 (while (string-match regexp filename) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1913 (setq filename (replace-match "\\1\\\\\\2" nil nil filename))) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1914 filename)))) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1915 |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1916 (defun comint-unquote-filename (filename) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1917 "Return FILENAME with quoted characters unquoted." |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1918 (if (null comint-file-name-quote-list) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1919 filename |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1920 (save-match-data |
15337
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1921 (let ((i 0)) |
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1922 (while (string-match "\\\\\\(.\\)" filename i) |
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1923 (setq filename (replace-match "\\1" nil nil filename)) |
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1924 (setq i (+ 1 (match-beginning 0))))) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1925 filename))) |
114 | 1926 |
584 | 1927 |
114 | 1928 (defun comint-dynamic-complete () |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1929 "Dynamically perform completion at point. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1930 Calls the functions in `comint-dynamic-complete-functions' to perform |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1931 completion until a function returns non-nil, at which point completion is |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1932 assumed to have occurred." |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1933 (interactive) |
12208
d10ef5c093ce
(comint-mode): Use make-local-hook.
Karl Heuer <kwzh@gnu.org>
parents:
12058
diff
changeset
|
1934 (run-hook-with-args-until-success 'comint-dynamic-complete-functions)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1935 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1936 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1937 (defun comint-dynamic-complete-filename () |
584 | 1938 "Dynamically complete the filename at point. |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1939 Completes if after a filename. See `comint-match-partial-filename' and |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1940 `comint-dynamic-complete-as-filename'. |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1941 This function is similar to `comint-replace-by-expanded-filename', except that |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1942 it won't change parts of the filename already entered in the buffer; it just |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1943 adds completion characters to the end of the filename. A completions listing |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1944 may be shown in a help buffer if completion is ambiguous. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1945 |
6256
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1946 Completion is dependent on the value of `comint-completion-addsuffix', |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1947 `comint-completion-recexact' and `comint-completion-fignore', and the timing of |
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1948 completions listing is dependent on the value of `comint-completion-autolist'. |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1949 |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1950 Returns t if successful." |
114 | 1951 (interactive) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1952 (if (comint-match-partial-filename) |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1953 (let ((directory-sep-char (if (memq system-type '(ms-dos windows-nt)) |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1954 ?\\ |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1955 ?/))) |
15337
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1956 (prog2 (or (window-minibuffer-p (selected-window)) |
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1957 (message "Completing file name...")) |
cf1e6f4dd2b0
(comint-dynamic-complete-filename) [ms-dos, windows-nt]:
Richard M. Stallman <rms@gnu.org>
parents:
14814
diff
changeset
|
1958 (comint-dynamic-complete-as-filename))))) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1959 |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1960 (defun comint-dynamic-complete-as-filename () |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1961 "Dynamically complete at point as a filename. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1962 See `comint-dynamic-complete-filename'. Returns t if successful." |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1963 (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) |
6256
3810012eb29f
(comint-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6239
diff
changeset
|
1964 (completion-ignored-extensions comint-completion-fignore) |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1965 ;; If we bind this, it breaks remote directory tracking in rlogin.el. |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1966 ;; I think it was originally bound to solve file completion problems, |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1967 ;; but subsequent changes may have made this unnecessary. sm. |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
1968 ;;(file-name-handler-alist nil) |
10830
a774e92de39c
Let file-name-handler-alist to nil in comint-dynamic-complete-as-filename and
Simon Marshall <simon@gnu.org>
parents:
10702
diff
changeset
|
1969 (minibuffer-p (window-minibuffer-p (selected-window))) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1970 (success t) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1971 (dirsuffix (cond ((not comint-completion-addsuffix) "") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1972 ((not (consp comint-completion-addsuffix)) "/") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1973 (t (car comint-completion-addsuffix)))) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1974 (filesuffix (cond ((not comint-completion-addsuffix) "") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1975 ((not (consp comint-completion-addsuffix)) " ") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1976 (t (cdr comint-completion-addsuffix)))) |
6847
9481abcaa7de
(comint-dynamic-complete-as-filename): Simplify.
Karl Heuer <kwzh@gnu.org>
parents:
6797
diff
changeset
|
1977 (filename (or (comint-match-partial-filename) "")) |
9481abcaa7de
(comint-dynamic-complete-as-filename): Simplify.
Karl Heuer <kwzh@gnu.org>
parents:
6797
diff
changeset
|
1978 (pathdir (file-name-directory filename)) |
9481abcaa7de
(comint-dynamic-complete-as-filename): Simplify.
Karl Heuer <kwzh@gnu.org>
parents:
6797
diff
changeset
|
1979 (pathnondir (file-name-nondirectory filename)) |
9481abcaa7de
(comint-dynamic-complete-as-filename): Simplify.
Karl Heuer <kwzh@gnu.org>
parents:
6797
diff
changeset
|
1980 (directory (if pathdir (comint-directory pathdir) default-directory)) |
10830
a774e92de39c
Let file-name-handler-alist to nil in comint-dynamic-complete-as-filename and
Simon Marshall <simon@gnu.org>
parents:
10702
diff
changeset
|
1981 (completion (file-name-completion pathnondir directory))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1982 (cond ((null completion) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1983 (message "No completions of %s" filename) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
1984 (setq success nil)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1985 ((eq completion t) ; Means already completed "file". |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1986 (insert filesuffix) |
10830
a774e92de39c
Let file-name-handler-alist to nil in comint-dynamic-complete-as-filename and
Simon Marshall <simon@gnu.org>
parents:
10702
diff
changeset
|
1987 (or minibuffer-p (message "Sole completion"))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1988 ((string-equal completion "") ; Means completion on "directory/". |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1989 (comint-dynamic-list-filename-completions)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1990 (t ; Completion string returned. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1991 (let ((file (concat (file-name-as-directory directory) completion))) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1992 (insert (comint-quote-filename |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1993 (substring (directory-file-name completion) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1994 (length pathnondir)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1995 (cond ((symbolp (file-name-completion completion directory)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1996 ;; We inserted a unique completion. |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
1997 (insert (if (file-directory-p file) dirsuffix filesuffix)) |
10830
a774e92de39c
Let file-name-handler-alist to nil in comint-dynamic-complete-as-filename and
Simon Marshall <simon@gnu.org>
parents:
10702
diff
changeset
|
1998 (or minibuffer-p (message "Completed"))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
1999 ((and comint-completion-recexact comint-completion-addsuffix |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2000 (string-equal pathnondir completion) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2001 (file-exists-p file)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2002 ;; It's not unique, but user wants shortest match. |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2003 (insert (if (file-directory-p file) dirsuffix filesuffix)) |
10830
a774e92de39c
Let file-name-handler-alist to nil in comint-dynamic-complete-as-filename and
Simon Marshall <simon@gnu.org>
parents:
10702
diff
changeset
|
2004 (or minibuffer-p (message "Completed shortest"))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2005 ((or comint-completion-autolist |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2006 (string-equal pathnondir completion)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2007 ;; It's not unique, list possible completions. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2008 (comint-dynamic-list-filename-completions)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2009 (t |
10830
a774e92de39c
Let file-name-handler-alist to nil in comint-dynamic-complete-as-filename and
Simon Marshall <simon@gnu.org>
parents:
10702
diff
changeset
|
2010 (or minibuffer-p (message "Partially completed"))))))) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2011 success)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2012 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2013 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2014 (defun comint-replace-by-expanded-filename () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2015 "Dynamically expand and complete the filename at point. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2016 Replace the filename with an expanded, canonicalised and completed replacement. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2017 \"Expanded\" means environment variables (e.g., $HOME) and `~'s are replaced |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2018 with the corresponding directories. \"Canonicalised\" means `..' and `.' are |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2019 removed, and the filename is made absolute instead of relative. For expansion |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2020 see `expand-file-name' and `substitute-in-file-name'. For completion see |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2021 `comint-dynamic-complete-filename'." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2022 (interactive) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2023 (replace-match (expand-file-name (comint-match-partial-filename)) t t) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2024 (comint-dynamic-complete-filename)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2025 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2026 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2027 (defun comint-dynamic-simple-complete (stub candidates) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2028 "Dynamically complete STUB from CANDIDATES list. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2029 This function inserts completion characters at point by completing STUB from |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2030 the strings in CANDIDATES. A completions listing may be shown in a help buffer |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2031 if completion is ambiguous. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2032 |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2033 Returns nil if no completion was inserted. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2034 Returns `sole' if completed with the only completion match. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2035 Returns `shortest' if completed with the shortest of the completion matches. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2036 Returns `partial' if completed as far as possible with the completion matches. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2037 Returns `listed' if a completion listing was shown. |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2038 |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2039 See also `comint-dynamic-complete-filename'." |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
2040 (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2041 (suffix (cond ((not comint-completion-addsuffix) "") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2042 ((not (consp comint-completion-addsuffix)) " ") |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2043 (t (cdr comint-completion-addsuffix)))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2044 (candidates (mapcar (function (lambda (x) (list x))) candidates)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2045 (completions (all-completions stub candidates))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2046 (cond ((null completions) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2047 (message "No completions of %s" stub) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2048 nil) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2049 ((= 1 (length completions)) ; Gotcha! |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2050 (let ((completion (car completions))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2051 (if (string-equal completion stub) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2052 (message "Sole completion") |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2053 (insert (substring completion (length stub))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2054 (message "Completed")) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2055 (insert suffix) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2056 'sole)) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2057 (t ; There's no unique completion. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2058 (let ((completion (try-completion stub candidates))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2059 ;; Insert the longest substring. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2060 (insert (substring completion (length stub))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2061 (cond ((and comint-completion-recexact comint-completion-addsuffix |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2062 (string-equal stub completion) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2063 (member completion completions)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2064 ;; It's not unique, but user wants shortest match. |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2065 (insert suffix) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2066 (message "Completed shortest") |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2067 'shortest) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2068 ((or comint-completion-autolist |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2069 (string-equal stub completion)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2070 ;; It's not unique, list possible completions. |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2071 (comint-dynamic-list-completions completions) |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2072 'listed) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2073 (t |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2074 (message "Partially completed") |
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2075 'partial))))))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2076 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2077 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2078 (defun comint-dynamic-list-filename-completions () |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2079 "List in help buffer possible completions of the filename at point." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2080 (interactive) |
15654
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
2081 (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
2082 ;; If we bind this, it breaks remote directory tracking in rlogin.el. |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
2083 ;; I think it was originally bound to solve file completion problems, |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
2084 ;; but subsequent changes may have made this unnecessary. sm. |
6f32894f4ad3
1. For fns like comint-postoutput-scroll-to-bottom on comint-output-filter-functions, don't count back using the length of STRING, as previous fns may have changed the buffer. Count from process-mark.
Simon Marshall <simon@gnu.org>
parents:
15541
diff
changeset
|
2085 ;;(file-name-handler-alist nil) |
6185
82a92cf44059
(comint-after-partial-filename-command,
Richard M. Stallman <rms@gnu.org>
parents:
6154
diff
changeset
|
2086 (filename (or (comint-match-partial-filename) "")) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2087 (pathdir (file-name-directory filename)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2088 (pathnondir (file-name-nondirectory filename)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2089 (directory (if pathdir (comint-directory pathdir) default-directory)) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2090 (completions (file-name-all-completions pathnondir directory))) |
11187
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2091 (if (not completions) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2092 (message "No completions of %s" filename) |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2093 (comint-dynamic-list-completions |
ac3611b5f490
Added support for special (quoted) characters in file names:
Simon Marshall <simon@gnu.org>
parents:
11156
diff
changeset
|
2094 (mapcar 'comint-quote-filename completions))))) |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2095 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2096 |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2097 (defun comint-dynamic-list-completions (completions) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2098 "List in help buffer sorted COMPLETIONS. |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2099 Typing SPC flushes the help buffer." |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2100 (let ((conf (current-window-configuration))) |
7846
46db50437ebb
(comint-dynamic-list-completions): No space in *Completions*.
Richard M. Stallman <rms@gnu.org>
parents:
7766
diff
changeset
|
2101 (with-output-to-temp-buffer "*Completions*" |
4872
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2102 (display-completion-list (sort completions 'string-lessp))) |
628cbf7e7005
(comint-after-partial-file-name-command):
Richard M. Stallman <rms@gnu.org>
parents:
4675
diff
changeset
|
2103 (message "Hit space to flush") |
5424
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2104 (let (key first) |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2105 (if (save-excursion |
7846
46db50437ebb
(comint-dynamic-list-completions): No space in *Completions*.
Richard M. Stallman <rms@gnu.org>
parents:
7766
diff
changeset
|
2106 (set-buffer (get-buffer "*Completions*")) |
5424
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2107 (setq key (read-key-sequence nil) |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2108 first (aref key 0)) |
10445
a657f6491234
Make sure the event read by comint-dynamic-list-completions isn't
Simon Marshall <simon@gnu.org>
parents:
10125
diff
changeset
|
2109 (and (consp first) (consp (event-start first)) |
5424
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2110 (eq (window-buffer (posn-window (event-start first))) |
7846
46db50437ebb
(comint-dynamic-list-completions): No space in *Completions*.
Richard M. Stallman <rms@gnu.org>
parents:
7766
diff
changeset
|
2111 (get-buffer "*Completions*")) |
5424
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2112 (eq (key-binding key) 'mouse-choose-completion))) |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2113 ;; If the user does mouse-choose-completion with the mouse, |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2114 ;; execute the command, then delete the completion window. |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2115 (progn |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2116 (mouse-choose-completion first) |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2117 (set-window-configuration conf)) |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2118 (if (eq first ?\ ) |
51eecae04837
(comint-last-output-start): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
5323
diff
changeset
|
2119 (set-window-configuration conf) |
8332
1b4a8157f36c
(comint-dynamic-list-completions): Listify the key
Richard M. Stallman <rms@gnu.org>
parents:
8266
diff
changeset
|
2120 (setq unread-command-events (listify-key-sequence key))))))) |
114 | 2121 |
14169 | 2122 ;; Converting process modes to use comint mode |
2123 ;; =========================================================================== | |
2124 ;; The code in the Emacs 19 distribution has all been modified to use comint | |
2125 ;; where needed. However, there are `third-party' packages out there that | |
2126 ;; still use the old shell mode. Here's a guide to conversion. | |
2127 ;; | |
2128 ;; Renaming variables | |
2129 ;; Most of the work is renaming variables and functions. These are the common | |
2130 ;; ones: | |
2131 ;; Local variables: | |
2132 ;; last-input-start comint-last-input-start | |
2133 ;; last-input-end comint-last-input-end | |
2134 ;; shell-prompt-pattern comint-prompt-regexp | |
2135 ;; shell-set-directory-error-hook <no equivalent> | |
2136 ;; Miscellaneous: | |
2137 ;; shell-set-directory <unnecessary> | |
2138 ;; shell-mode-map comint-mode-map | |
2139 ;; Commands: | |
2140 ;; shell-send-input comint-send-input | |
2141 ;; shell-send-eof comint-delchar-or-maybe-eof | |
2142 ;; kill-shell-input comint-kill-input | |
2143 ;; interrupt-shell-subjob comint-interrupt-subjob | |
2144 ;; stop-shell-subjob comint-stop-subjob | |
2145 ;; quit-shell-subjob comint-quit-subjob | |
2146 ;; kill-shell-subjob comint-kill-subjob | |
2147 ;; kill-output-from-shell comint-kill-output | |
2148 ;; show-output-from-shell comint-show-output | |
2149 ;; copy-last-shell-input Use comint-previous-input/comint-next-input | |
2150 ;; | |
2151 ;; SHELL-SET-DIRECTORY is gone, its functionality taken over by | |
2152 ;; SHELL-DIRECTORY-TRACKER, the shell mode's comint-input-filter-functions. | |
2153 ;; Comint mode does not provide functionality equivalent to | |
2154 ;; shell-set-directory-error-hook; it is gone. | |
2155 ;; | |
2156 ;; comint-last-input-start is provided for modes which want to munge | |
2157 ;; the buffer after input is sent, perhaps because the inferior | |
2158 ;; insists on echoing the input. The LAST-INPUT-START variable in | |
2159 ;; the old shell package was used to implement a history mechanism, | |
2160 ;; but you should think twice before using comint-last-input-start | |
2161 ;; for this; the input history ring often does the job better. | |
2162 ;; | |
2163 ;; If you are implementing some process-in-a-buffer mode, called foo-mode, do | |
2164 ;; *not* create the comint-mode local variables in your foo-mode function. | |
2165 ;; This is not modular. Instead, call comint-mode, and let *it* create the | |
2166 ;; necessary comint-specific local variables. Then create the | |
2167 ;; foo-mode-specific local variables in foo-mode. Set the buffer's keymap to | |
2168 ;; be foo-mode-map, and its mode to be foo-mode. Set the comint-mode hooks | |
2169 ;; (comint-{prompt-regexp, input-filter, input-filter-functions, | |
2170 ;; get-old-input) that need to be different from the defaults. Call | |
2171 ;; foo-mode-hook, and you're done. Don't run the comint-mode hook yourself; | |
2172 ;; comint-mode will take care of it. The following example, from shell.el, | |
2173 ;; is typical: | |
2174 ;; | |
2175 ;; (defvar shell-mode-map '()) | |
2176 ;; (cond ((not shell-mode-map) | |
2177 ;; (setq shell-mode-map (copy-keymap comint-mode-map)) | |
2178 ;; (define-key shell-mode-map "\C-c\C-f" 'shell-forward-command) | |
2179 ;; (define-key shell-mode-map "\C-c\C-b" 'shell-backward-command) | |
2180 ;; (define-key shell-mode-map "\t" 'comint-dynamic-complete) | |
2181 ;; (define-key shell-mode-map "\M-?" | |
2182 ;; 'comint-dynamic-list-filename-completions))) | |
2183 ;; | |
2184 ;; (defun shell-mode () | |
2185 ;; (interactive) | |
2186 ;; (comint-mode) | |
2187 ;; (setq comint-prompt-regexp shell-prompt-pattern) | |
2188 ;; (setq major-mode 'shell-mode) | |
2189 ;; (setq mode-name "Shell") | |
2190 ;; (use-local-map shell-mode-map) | |
2191 ;; (make-local-variable 'shell-directory-stack) | |
2192 ;; (setq shell-directory-stack nil) | |
2193 ;; (add-hook 'comint-input-filter-functions 'shell-directory-tracker) | |
2194 ;; (run-hooks 'shell-mode-hook)) | |
2195 ;; | |
2196 ;; | |
2197 ;; Note that make-comint is different from make-shell in that it | |
2198 ;; doesn't have a default program argument. If you give make-shell | |
2199 ;; a program name of NIL, it cleverly chooses one of explicit-shell-name, | |
2200 ;; $ESHELL, $SHELL, or /bin/sh. If you give make-comint a program argument | |
2201 ;; of NIL, it barfs. Adjust your code accordingly... | |
2202 ;; | |
2203 ;; Completion for comint-mode users | |
2204 ;; | |
2205 ;; For modes that use comint-mode, comint-dynamic-complete-functions is the | |
2206 ;; hook to add completion functions to. Functions on this list should return | |
2207 ;; non-nil if completion occurs (i.e., further completion should not occur). | |
2208 ;; You could use comint-dynamic-simple-complete to do the bulk of the | |
2209 ;; completion job. | |
584 | 2210 |
2211 (provide 'comint) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
638
diff
changeset
|
2212 |
14169 | 2213 ;; comint.el ends here |