diff options
| author | Simon Marshall | 1996-07-12 07:32:45 +0000 |
|---|---|---|
| committer | Simon Marshall | 1996-07-12 07:32:45 +0000 |
| commit | 107d7589ed22c3b23a9903544286bd2c1910fe07 (patch) | |
| tree | 021d30816b6c37403e3134137d0583b844fcb4f6 /lisp | |
| parent | 98f84f52d43a887e63f85a0a1f80fe2987a1db92 (diff) | |
| download | emacs-107d7589ed22c3b23a9903544286bd2c1910fe07.tar.gz emacs-107d7589ed22c3b23a9903544286bd2c1910fe07.zip | |
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.
2. Don't bind file-name-handler-alist, it can break dir tracking.
3. Expand ^ in input only at boi.
4. Use new comint-file-name-regexp as source of valid chars in filenames.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/comint.el | 103 |
1 files changed, 57 insertions, 46 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 019fff11572..cc683d7d651 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -107,34 +107,35 @@ | |||
| 107 | ;; Buffer Local Variables: | 107 | ;; Buffer Local Variables: |
| 108 | ;;============================================================================ | 108 | ;;============================================================================ |
| 109 | ;; Comint mode buffer local variables: | 109 | ;; Comint mode buffer local variables: |
| 110 | ;; comint-prompt-regexp - string comint-bol uses to match prompt | 110 | ;; comint-prompt-regexp string comint-bol uses to match prompt |
| 111 | ;; comint-delimiter-argument-list - list For delimiters and arguments | 111 | ;; comint-delimiter-argument-list list For delimiters and arguments |
| 112 | ;; comint-last-input-start - marker Handy if inferior always echoes | 112 | ;; comint-last-input-start marker Handy if inferior always echoes |
| 113 | ;; comint-last-input-end - marker For comint-kill-output command | 113 | ;; comint-last-input-end marker For comint-kill-output command |
| 114 | ;; comint-input-ring-size - integer For the input history | 114 | ;; comint-input-ring-size integer For the input history |
| 115 | ;; comint-input-ring - ring mechanism | 115 | ;; comint-input-ring ring mechanism |
| 116 | ;; comint-input-ring-index - number ... | 116 | ;; comint-input-ring-index number ... |
| 117 | ;; comint-input-autoexpand - symbol ... | 117 | ;; comint-input-autoexpand symbol ... |
| 118 | ;; comint-input-ignoredups - boolean ... | 118 | ;; comint-input-ignoredups boolean ... |
| 119 | ;; comint-last-input-match - string ... | 119 | ;; comint-last-input-match string ... |
| 120 | ;; comint-dynamic-complete-functions - hook For the completion mechanism | 120 | ;; comint-dynamic-complete-functions hook For the completion mechanism |
| 121 | ;; comint-completion-fignore - list ... | 121 | ;; comint-completion-fignore list ... |
| 122 | ;; comint-file-name-quote-list - list ... | 122 | ;; comint-file-name-regexp regexp ... |
| 123 | ;; comint-get-old-input - function Hooks for specific | 123 | ;; comint-file-name-quote-list list ... |
| 124 | ;; comint-input-filter-functions - hook process-in-a-buffer | 124 | ;; comint-get-old-input function Hooks for specific |
| 125 | ;; comint-output-filter-functions - hook function modes. | 125 | ;; comint-input-filter-functions hook process-in-a-buffer |
| 126 | ;; comint-input-filter - function ... | 126 | ;; comint-output-filter-functions hook function modes. |
| 127 | ;; comint-input-sender - function ... | 127 | ;; comint-input-filter function ... |
| 128 | ;; comint-eol-on-send - boolean ... | 128 | ;; comint-input-sender function ... |
| 129 | ;; comint-process-echoes - boolean ... | 129 | ;; comint-eol-on-send boolean ... |
| 130 | ;; comint-scroll-to-bottom-on-input - symbol For scroll behavior | 130 | ;; comint-process-echoes boolean ... |
| 131 | ;; comint-scroll-to-bottom-on-output - symbol ... | 131 | ;; comint-scroll-to-bottom-on-input symbol For scroll behavior |
| 132 | ;; comint-scroll-show-maximum-output - boolean... | 132 | ;; comint-scroll-to-bottom-on-output symbol ... |
| 133 | ;; comint-scroll-show-maximum-output boolean ... | ||
| 133 | ;; | 134 | ;; |
| 134 | ;; Comint mode non-buffer local variables: | 135 | ;; Comint mode non-buffer local variables: |
| 135 | ;; comint-completion-addsuffix - boolean/cons For file name completion | 136 | ;; comint-completion-addsuffix boolean/cons For file name |
| 136 | ;; comint-completion-autolist - boolean behavior | 137 | ;; comint-completion-autolist boolean completion behavior |
| 137 | ;; comint-completion-recexact - boolean ... | 138 | ;; comint-completion-recexact boolean ... |
| 138 | 139 | ||
| 139 | (defvar comint-prompt-regexp "^" | 140 | (defvar comint-prompt-regexp "^" |
| 140 | "Regexp to recognise prompts in the inferior process. | 141 | "Regexp to recognise prompts in the inferior process. |
| @@ -262,7 +263,10 @@ This variable is buffer-local.") | |||
| 262 | (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom) | 263 | (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom) |
| 263 | "Functions to call after output is inserted into the buffer. | 264 | "Functions to call after output is inserted into the buffer. |
| 264 | One possible function is `comint-postoutput-scroll-to-bottom'. | 265 | One possible function is `comint-postoutput-scroll-to-bottom'. |
| 265 | These functions get one argument, a string containing the text just inserted. | 266 | These functions get one argument, a string containing the text as originally |
| 267 | inserted. Note that this might not be the same as the buffer contents between | ||
| 268 | `comint-last-output-start' and the buffer's `process-mark', if other filter | ||
| 269 | functions have already modified the buffer. | ||
| 266 | 270 | ||
| 267 | This variable is buffer-local.") | 271 | This variable is buffer-local.") |
| 268 | 272 | ||
| @@ -393,6 +397,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'." | |||
| 393 | (make-local-variable 'comint-ptyp) | 397 | (make-local-variable 'comint-ptyp) |
| 394 | (make-local-variable 'comint-exec-hook) | 398 | (make-local-variable 'comint-exec-hook) |
| 395 | (make-local-variable 'comint-process-echoes) | 399 | (make-local-variable 'comint-process-echoes) |
| 400 | (make-local-variable 'comint-file-name-regexp) | ||
| 396 | (make-local-variable 'comint-file-name-quote-list) | 401 | (make-local-variable 'comint-file-name-quote-list) |
| 397 | (run-hooks 'comint-mode-hook)) | 402 | (run-hooks 'comint-mode-hook)) |
| 398 | 403 | ||
| @@ -895,7 +900,7 @@ See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'. | |||
| 895 | Returns t if successful." | 900 | Returns t if successful." |
| 896 | (interactive) | 901 | (interactive) |
| 897 | (if (and comint-input-autoexpand | 902 | (if (and comint-input-autoexpand |
| 898 | (string-match "[!^]" (funcall comint-get-old-input)) | 903 | (string-match "!\\|^\\^" (funcall comint-get-old-input)) |
| 899 | (save-excursion (beginning-of-line) | 904 | (save-excursion (beginning-of-line) |
| 900 | (looking-at comint-prompt-regexp))) | 905 | (looking-at comint-prompt-regexp))) |
| 901 | ;; Looks like there might be history references in the command. | 906 | ;; Looks like there might be history references in the command. |
| @@ -1280,12 +1285,11 @@ This function should be in the list `comint-output-filter-functions'." | |||
| 1280 | (select-window window) | 1285 | (select-window window) |
| 1281 | (if (and (< (point) (process-mark process)) | 1286 | (if (and (< (point) (process-mark process)) |
| 1282 | (or (eq scroll t) (eq scroll 'all) | 1287 | (or (eq scroll t) (eq scroll 'all) |
| 1283 | ;; Maybe user wants point to jump to the end. | 1288 | ;; Maybe user wants point to jump to end. |
| 1284 | (and (eq scroll 'this) (eq selected window)) | 1289 | (and (eq scroll 'this) (eq selected window)) |
| 1285 | (and (eq scroll 'others) (not (eq selected window))) | 1290 | (and (eq scroll 'others) (not (eq selected window))) |
| 1286 | ;; If point was at the end, keep it at the end. | 1291 | ;; If point was at the end, keep it at end. |
| 1287 | (>= (point) | 1292 | (>= (point) comint-last-output-start))) |
| 1288 | (- (process-mark process) (length string))))) | ||
| 1289 | (goto-char (process-mark process))) | 1293 | (goto-char (process-mark process))) |
| 1290 | ;; Optionally scroll so that the text | 1294 | ;; Optionally scroll so that the text |
| 1291 | ;; ends at the bottom of the window. | 1295 | ;; ends at the bottom of the window. |
| @@ -1303,7 +1307,7 @@ This function should be in the list `comint-output-filter-functions'." | |||
| 1303 | This function could be on `comint-output-filter-functions' or bound to a key." | 1307 | This function could be on `comint-output-filter-functions' or bound to a key." |
| 1304 | (interactive) | 1308 | (interactive) |
| 1305 | (save-excursion | 1309 | (save-excursion |
| 1306 | (goto-char (point-max)) | 1310 | (goto-char (process-mark (get-buffer-process (current-buffer)))) |
| 1307 | (forward-line (- comint-buffer-maximum-size)) | 1311 | (forward-line (- comint-buffer-maximum-size)) |
| 1308 | (beginning-of-line) | 1312 | (beginning-of-line) |
| 1309 | (delete-region (point-min) (point)))) | 1313 | (delete-region (point-min) (point)))) |
| @@ -1823,6 +1827,11 @@ Note that this applies to `comint-dynamic-complete-filename' only.") | |||
| 1823 | This is used by comint's and shell's completion functions, and by shell's | 1827 | This is used by comint's and shell's completion functions, and by shell's |
| 1824 | directory tracking functions.") | 1828 | directory tracking functions.") |
| 1825 | 1829 | ||
| 1830 | (defvar comint-file-name-regexp nil | ||
| 1831 | "Regexp of characters valid in a file name. | ||
| 1832 | |||
| 1833 | This is a good thing to set in mode hooks.") | ||
| 1834 | |||
| 1826 | (defvar comint-file-name-quote-list nil | 1835 | (defvar comint-file-name-quote-list nil |
| 1827 | "List of characters to quote with `\\' when in a file name. | 1836 | "List of characters to quote with `\\' when in a file name. |
| 1828 | 1837 | ||
| @@ -1875,7 +1884,7 @@ interpreter (e.g., the percent notation of cmd.exe on NT)." | |||
| 1875 | (defun comint-match-partial-filename () | 1884 | (defun comint-match-partial-filename () |
| 1876 | "Return the filename at point, or nil if non is found. | 1885 | "Return the filename at point, or nil if non is found. |
| 1877 | Environment variables are substituted. See `comint-word'." | 1886 | Environment variables are substituted. See `comint-word'." |
| 1878 | (let ((filename (comint-word "~/A-Za-z0-9+@:_.$#%,={}-"))) | 1887 | (let ((filename (comint-word comint-file-name-regexp))) |
| 1879 | (and filename (comint-substitute-in-file-name | 1888 | (and filename (comint-substitute-in-file-name |
| 1880 | (comint-unquote-filename filename))))) | 1889 | (comint-unquote-filename filename))))) |
| 1881 | 1890 | ||
| @@ -1930,10 +1939,9 @@ completions listing is dependent on the value of `comint-completion-autolist'. | |||
| 1930 | Returns t if successful." | 1939 | Returns t if successful." |
| 1931 | (interactive) | 1940 | (interactive) |
| 1932 | (if (comint-match-partial-filename) | 1941 | (if (comint-match-partial-filename) |
| 1933 | (let ((directory-sep-char ?/)) | 1942 | (let ((directory-sep-char (if (memq system-type '(ms-dos windows-nt)) |
| 1934 | (if (memq system-type '(ms-dos windows-nt)) | 1943 | ?\\ |
| 1935 | ; The default shells on these systems require backslashed names | 1944 | ?/))) |
| 1936 | (setq directory-sep-char ?\\)) | ||
| 1937 | (prog2 (or (window-minibuffer-p (selected-window)) | 1945 | (prog2 (or (window-minibuffer-p (selected-window)) |
| 1938 | (message "Completing file name...")) | 1946 | (message "Completing file name...")) |
| 1939 | (comint-dynamic-complete-as-filename))))) | 1947 | (comint-dynamic-complete-as-filename))))) |
| @@ -1941,10 +1949,12 @@ Returns t if successful." | |||
| 1941 | (defun comint-dynamic-complete-as-filename () | 1949 | (defun comint-dynamic-complete-as-filename () |
| 1942 | "Dynamically complete at point as a filename. | 1950 | "Dynamically complete at point as a filename. |
| 1943 | See `comint-dynamic-complete-filename'. Returns t if successful." | 1951 | See `comint-dynamic-complete-filename'. Returns t if successful." |
| 1944 | (let* ((completion-ignore-case | 1952 | (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) |
| 1945 | (if (memq system-type '(ms-dos windows-nt)) t nil)) | ||
| 1946 | (completion-ignored-extensions comint-completion-fignore) | 1953 | (completion-ignored-extensions comint-completion-fignore) |
| 1947 | (file-name-handler-alist nil) | 1954 | ;; If we bind this, it breaks remote directory tracking in rlogin.el. |
| 1955 | ;; I think it was originally bound to solve file completion problems, | ||
| 1956 | ;; but subsequent changes may have made this unnecessary. sm. | ||
| 1957 | ;;(file-name-handler-alist nil) | ||
| 1948 | (minibuffer-p (window-minibuffer-p (selected-window))) | 1958 | (minibuffer-p (window-minibuffer-p (selected-window))) |
| 1949 | (success t) | 1959 | (success t) |
| 1950 | (dirsuffix (cond ((not comint-completion-addsuffix) "") | 1960 | (dirsuffix (cond ((not comint-completion-addsuffix) "") |
| @@ -2016,8 +2026,7 @@ Returns `partial' if completed as far as possible with the completion matches. | |||
| 2016 | Returns `listed' if a completion listing was shown. | 2026 | Returns `listed' if a completion listing was shown. |
| 2017 | 2027 | ||
| 2018 | See also `comint-dynamic-complete-filename'." | 2028 | See also `comint-dynamic-complete-filename'." |
| 2019 | (let* ((completion-ignore-case | 2029 | (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) |
| 2020 | (if (memq system-type '(ms-dos windows-nt)) t nil)) | ||
| 2021 | (suffix (cond ((not comint-completion-addsuffix) "") | 2030 | (suffix (cond ((not comint-completion-addsuffix) "") |
| 2022 | ((not (consp comint-completion-addsuffix)) " ") | 2031 | ((not (consp comint-completion-addsuffix)) " ") |
| 2023 | (t (cdr comint-completion-addsuffix)))) | 2032 | (t (cdr comint-completion-addsuffix)))) |
| @@ -2058,9 +2067,11 @@ See also `comint-dynamic-complete-filename'." | |||
| 2058 | (defun comint-dynamic-list-filename-completions () | 2067 | (defun comint-dynamic-list-filename-completions () |
| 2059 | "List in help buffer possible completions of the filename at point." | 2068 | "List in help buffer possible completions of the filename at point." |
| 2060 | (interactive) | 2069 | (interactive) |
| 2061 | (let* ((completion-ignore-case | 2070 | (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) |
| 2062 | (if (memq system-type '(ms-dos windows-nt)) t nil)) | 2071 | ;; If we bind this, it breaks remote directory tracking in rlogin.el. |
| 2063 | (file-name-handler-alist nil) | 2072 | ;; I think it was originally bound to solve file completion problems, |
| 2073 | ;; but subsequent changes may have made this unnecessary. sm. | ||
| 2074 | ;;(file-name-handler-alist nil) | ||
| 2064 | (filename (or (comint-match-partial-filename) "")) | 2075 | (filename (or (comint-match-partial-filename) "")) |
| 2065 | (pathdir (file-name-directory filename)) | 2076 | (pathdir (file-name-directory filename)) |
| 2066 | (pathnondir (file-name-nondirectory filename)) | 2077 | (pathnondir (file-name-nondirectory filename)) |