Commit 107d7589 authored by Simon Marshall's avatar Simon Marshall
Browse files

1. For fns like comint-postoutput-scroll-to-bottom on...

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.
parent 98f84f52
...@@ -107,34 +107,35 @@ ...@@ -107,34 +107,35 @@
;; Buffer Local Variables: ;; Buffer Local Variables:
;;============================================================================ ;;============================================================================
;; Comint mode buffer local variables: ;; Comint mode buffer local variables:
;; comint-prompt-regexp - string comint-bol uses to match prompt ;; comint-prompt-regexp string comint-bol uses to match prompt
;; comint-delimiter-argument-list - list For delimiters and arguments ;; comint-delimiter-argument-list list For delimiters and arguments
;; comint-last-input-start - marker Handy if inferior always echoes ;; comint-last-input-start marker Handy if inferior always echoes
;; comint-last-input-end - marker For comint-kill-output command ;; comint-last-input-end marker For comint-kill-output command
;; comint-input-ring-size - integer For the input history ;; comint-input-ring-size integer For the input history
;; comint-input-ring - ring mechanism ;; comint-input-ring ring mechanism
;; comint-input-ring-index - number ... ;; comint-input-ring-index number ...
;; comint-input-autoexpand - symbol ... ;; comint-input-autoexpand symbol ...
;; comint-input-ignoredups - boolean ... ;; comint-input-ignoredups boolean ...
;; comint-last-input-match - string ... ;; comint-last-input-match string ...
;; comint-dynamic-complete-functions - hook For the completion mechanism ;; comint-dynamic-complete-functions hook For the completion mechanism
;; comint-completion-fignore - list ... ;; comint-completion-fignore list ...
;; comint-file-name-quote-list - list ... ;; comint-file-name-regexp regexp ...
;; comint-get-old-input - function Hooks for specific ;; comint-file-name-quote-list list ...
;; comint-input-filter-functions - hook process-in-a-buffer ;; comint-get-old-input function Hooks for specific
;; comint-output-filter-functions - hook function modes. ;; comint-input-filter-functions hook process-in-a-buffer
;; comint-input-filter - function ... ;; comint-output-filter-functions hook function modes.
;; comint-input-sender - function ... ;; comint-input-filter function ...
;; comint-eol-on-send - boolean ... ;; comint-input-sender function ...
;; comint-process-echoes - boolean ... ;; comint-eol-on-send boolean ...
;; comint-scroll-to-bottom-on-input - symbol For scroll behavior ;; comint-process-echoes boolean ...
;; comint-scroll-to-bottom-on-output - symbol ... ;; comint-scroll-to-bottom-on-input symbol For scroll behavior
;; comint-scroll-show-maximum-output - boolean... ;; comint-scroll-to-bottom-on-output symbol ...
;; comint-scroll-show-maximum-output boolean ...
;; ;;
;; Comint mode non-buffer local variables: ;; Comint mode non-buffer local variables:
;; comint-completion-addsuffix - boolean/cons For file name completion ;; comint-completion-addsuffix boolean/cons For file name
;; comint-completion-autolist - boolean behavior ;; comint-completion-autolist boolean completion behavior
;; comint-completion-recexact - boolean ... ;; comint-completion-recexact boolean ...
(defvar comint-prompt-regexp "^" (defvar comint-prompt-regexp "^"
"Regexp to recognise prompts in the inferior process. "Regexp to recognise prompts in the inferior process.
...@@ -262,7 +263,10 @@ This variable is buffer-local.") ...@@ -262,7 +263,10 @@ This variable is buffer-local.")
(defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom) (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom)
"Functions to call after output is inserted into the buffer. "Functions to call after output is inserted into the buffer.
One possible function is `comint-postoutput-scroll-to-bottom'. One possible function is `comint-postoutput-scroll-to-bottom'.
These functions get one argument, a string containing the text just inserted. These functions get one argument, a string containing the text as originally
inserted. Note that this might not be the same as the buffer contents between
`comint-last-output-start' and the buffer's `process-mark', if other filter
functions have already modified the buffer.
This variable is buffer-local.") This variable is buffer-local.")
...@@ -393,6 +397,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'." ...@@ -393,6 +397,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
(make-local-variable 'comint-ptyp) (make-local-variable 'comint-ptyp)
(make-local-variable 'comint-exec-hook) (make-local-variable 'comint-exec-hook)
(make-local-variable 'comint-process-echoes) (make-local-variable 'comint-process-echoes)
(make-local-variable 'comint-file-name-regexp)
(make-local-variable 'comint-file-name-quote-list) (make-local-variable 'comint-file-name-quote-list)
(run-hooks 'comint-mode-hook)) (run-hooks 'comint-mode-hook))
...@@ -895,7 +900,7 @@ See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'. ...@@ -895,7 +900,7 @@ See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'.
Returns t if successful." Returns t if successful."
(interactive) (interactive)
(if (and comint-input-autoexpand (if (and comint-input-autoexpand
(string-match "[!^]" (funcall comint-get-old-input)) (string-match "!\\|^\\^" (funcall comint-get-old-input))
(save-excursion (beginning-of-line) (save-excursion (beginning-of-line)
(looking-at comint-prompt-regexp))) (looking-at comint-prompt-regexp)))
;; Looks like there might be history references in the command. ;; 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,12 +1285,11 @@ This function should be in the list `comint-output-filter-functions'."
(select-window window) (select-window window)
(if (and (< (point) (process-mark process)) (if (and (< (point) (process-mark process))
(or (eq scroll t) (eq scroll 'all) (or (eq scroll t) (eq scroll 'all)
;; Maybe user wants point to jump to the end. ;; Maybe user wants point to jump to end.
(and (eq scroll 'this) (eq selected window)) (and (eq scroll 'this) (eq selected window))
(and (eq scroll 'others) (not (eq selected window))) (and (eq scroll 'others) (not (eq selected window)))
;; If point was at the end, keep it at the end. ;; If point was at the end, keep it at end.
(>= (point) (>= (point) comint-last-output-start)))
(- (process-mark process) (length string)))))
(goto-char (process-mark process))) (goto-char (process-mark process)))
;; Optionally scroll so that the text ;; Optionally scroll so that the text
;; ends at the bottom of the window. ;; ends at the bottom of the window.
...@@ -1303,7 +1307,7 @@ This function should be in the list `comint-output-filter-functions'." ...@@ -1303,7 +1307,7 @@ This function should be in the list `comint-output-filter-functions'."
This function could be on `comint-output-filter-functions' or bound to a key." This function could be on `comint-output-filter-functions' or bound to a key."
(interactive) (interactive)
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (process-mark (get-buffer-process (current-buffer))))
(forward-line (- comint-buffer-maximum-size)) (forward-line (- comint-buffer-maximum-size))
(beginning-of-line) (beginning-of-line)
(delete-region (point-min) (point)))) (delete-region (point-min) (point))))
...@@ -1823,6 +1827,11 @@ Note that this applies to `comint-dynamic-complete-filename' only.") ...@@ -1823,6 +1827,11 @@ Note that this applies to `comint-dynamic-complete-filename' only.")
This is used by comint's and shell's completion functions, and by shell's This is used by comint's and shell's completion functions, and by shell's
directory tracking functions.") directory tracking functions.")
(defvar comint-file-name-regexp nil
"Regexp of characters valid in a file name.
This is a good thing to set in mode hooks.")
(defvar comint-file-name-quote-list nil (defvar comint-file-name-quote-list nil
"List of characters to quote with `\\' when in a file name. "List of characters to quote with `\\' when in a file name.
...@@ -1875,7 +1884,7 @@ interpreter (e.g., the percent notation of cmd.exe on NT)." ...@@ -1875,7 +1884,7 @@ interpreter (e.g., the percent notation of cmd.exe on NT)."
(defun comint-match-partial-filename () (defun comint-match-partial-filename ()
"Return the filename at point, or nil if non is found. "Return the filename at point, or nil if non is found.
Environment variables are substituted. See `comint-word'." Environment variables are substituted. See `comint-word'."
(let ((filename (comint-word "~/A-Za-z0-9+@:_.$#%,={}-"))) (let ((filename (comint-word comint-file-name-regexp)))
(and filename (comint-substitute-in-file-name (and filename (comint-substitute-in-file-name
(comint-unquote-filename filename))))) (comint-unquote-filename filename)))))
...@@ -1930,10 +1939,9 @@ completions listing is dependent on the value of `comint-completion-autolist'. ...@@ -1930,10 +1939,9 @@ completions listing is dependent on the value of `comint-completion-autolist'.
Returns t if successful." Returns t if successful."
(interactive) (interactive)
(if (comint-match-partial-filename) (if (comint-match-partial-filename)
(let ((directory-sep-char ?/)) (let ((directory-sep-char (if (memq system-type '(ms-dos windows-nt))
(if (memq system-type '(ms-dos windows-nt)) ?\\
; The default shells on these systems require backslashed names ?/)))
(setq directory-sep-char ?\\))
(prog2 (or (window-minibuffer-p (selected-window)) (prog2 (or (window-minibuffer-p (selected-window))
(message "Completing file name...")) (message "Completing file name..."))
(comint-dynamic-complete-as-filename))))) (comint-dynamic-complete-as-filename)))))
...@@ -1941,10 +1949,12 @@ Returns t if successful." ...@@ -1941,10 +1949,12 @@ Returns t if successful."
(defun comint-dynamic-complete-as-filename () (defun comint-dynamic-complete-as-filename ()
"Dynamically complete at point as a filename. "Dynamically complete at point as a filename.
See `comint-dynamic-complete-filename'. Returns t if successful." See `comint-dynamic-complete-filename'. Returns t if successful."
(let* ((completion-ignore-case (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt)))
(if (memq system-type '(ms-dos windows-nt)) t nil))
(completion-ignored-extensions comint-completion-fignore) (completion-ignored-extensions comint-completion-fignore)
(file-name-handler-alist nil) ;; If we bind this, it breaks remote directory tracking in rlogin.el.
;; I think it was originally bound to solve file completion problems,
;; but subsequent changes may have made this unnecessary. sm.
;;(file-name-handler-alist nil)
(minibuffer-p (window-minibuffer-p (selected-window))) (minibuffer-p (window-minibuffer-p (selected-window)))
(success t) (success t)
(dirsuffix (cond ((not comint-completion-addsuffix) "") (dirsuffix (cond ((not comint-completion-addsuffix) "")
...@@ -2016,8 +2026,7 @@ Returns `partial' if completed as far as possible with the completion matches. ...@@ -2016,8 +2026,7 @@ Returns `partial' if completed as far as possible with the completion matches.
Returns `listed' if a completion listing was shown. Returns `listed' if a completion listing was shown.
See also `comint-dynamic-complete-filename'." See also `comint-dynamic-complete-filename'."
(let* ((completion-ignore-case (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt)))
(if (memq system-type '(ms-dos windows-nt)) t nil))
(suffix (cond ((not comint-completion-addsuffix) "") (suffix (cond ((not comint-completion-addsuffix) "")
((not (consp comint-completion-addsuffix)) " ") ((not (consp comint-completion-addsuffix)) " ")
(t (cdr comint-completion-addsuffix)))) (t (cdr comint-completion-addsuffix))))
...@@ -2058,9 +2067,11 @@ See also `comint-dynamic-complete-filename'." ...@@ -2058,9 +2067,11 @@ See also `comint-dynamic-complete-filename'."
(defun comint-dynamic-list-filename-completions () (defun comint-dynamic-list-filename-completions ()
"List in help buffer possible completions of the filename at point." "List in help buffer possible completions of the filename at point."
(interactive) (interactive)
(let* ((completion-ignore-case (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt)))
(if (memq system-type '(ms-dos windows-nt)) t nil)) ;; If we bind this, it breaks remote directory tracking in rlogin.el.
(file-name-handler-alist nil) ;; I think it was originally bound to solve file completion problems,
;; but subsequent changes may have made this unnecessary. sm.
;;(file-name-handler-alist nil)
(filename (or (comint-match-partial-filename) "")) (filename (or (comint-match-partial-filename) ""))
(pathdir (file-name-directory filename)) (pathdir (file-name-directory filename))
(pathnondir (file-name-nondirectory filename)) (pathnondir (file-name-nondirectory filename))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment