aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/comint.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el67
1 files changed, 33 insertions, 34 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index 217bd4e8b6d..0ce7053c031 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -636,7 +636,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
636 (setq-local comint-last-input-start (point-min-marker)) 636 (setq-local comint-last-input-start (point-min-marker))
637 (setq-local comint-last-input-end (point-min-marker)) 637 (setq-local comint-last-input-end (point-min-marker))
638 (setq-local comint-last-output-start (make-marker)) 638 (setq-local comint-last-output-start (make-marker))
639 (make-local-variable 'comint-last-prompt-overlay) 639 (make-local-variable 'comint-last-prompt)
640 (make-local-variable 'comint-prompt-regexp) ; Don't set; default 640 (make-local-variable 'comint-prompt-regexp) ; Don't set; default
641 (make-local-variable 'comint-input-ring-size) ; ...to global val. 641 (make-local-variable 'comint-input-ring-size) ; ...to global val.
642 (make-local-variable 'comint-input-ring) 642 (make-local-variable 'comint-input-ring)
@@ -1562,8 +1562,9 @@ or to the last history element for a backward search."
1562 "Save a function restoring the state of input history search. 1562 "Save a function restoring the state of input history search.
1563Save `comint-input-ring-index' to the additional state parameter 1563Save `comint-input-ring-index' to the additional state parameter
1564in the search status stack." 1564in the search status stack."
1565 `(lambda (cmd) 1565 (let ((index comint-input-ring-index))
1566 (comint-history-isearch-pop-state cmd ,comint-input-ring-index))) 1566 (lambda (cmd)
1567 (comint-history-isearch-pop-state cmd index))))
1567 1568
1568(defun comint-history-isearch-pop-state (_cmd hist-pos) 1569(defun comint-history-isearch-pop-state (_cmd hist-pos)
1569 "Restore the input history search state. 1570 "Restore the input history search state.
@@ -1902,21 +1903,24 @@ either globally or locally.")
1902 "If nil, Comint will interpret `carriage control' characters in output. 1903 "If nil, Comint will interpret `carriage control' characters in output.
1903See `comint-carriage-motion' for details.") 1904See `comint-carriage-motion' for details.")
1904 1905
1905;; When non-nil, this is an overlay over the last recognized prompt in 1906(defvar comint-last-prompt nil
1906;; the buffer; it is used when highlighting the prompt. 1907 "Markers pointing to the last prompt.
1907(defvar comint-last-prompt-overlay nil) 1908If non-nil, a cons cell containing markers. The car points to
1909the start, the cdr to the end of the last prompt recognized.")
1908 1910
1909(defun comint-snapshot-last-prompt () 1911(defun comint-snapshot-last-prompt ()
1910 "`snapshot' any current `comint-last-prompt-overlay'. 1912 "Snapshot the current `comint-last-prompt'.
1911Freeze its attributes in place, even when more input comes along 1913Freezes the `font-lock-face' text property in place."
1912and moves the prompt overlay." 1914 (when comint-last-prompt
1913 (when comint-last-prompt-overlay 1915 (with-silent-modifications
1914 (let ((inhibit-read-only t)) 1916 (add-text-properties
1915 (with-silent-modifications 1917 (car comint-last-prompt)
1916 (add-text-properties 1918 (cdr comint-last-prompt)
1917 (overlay-start comint-last-prompt-overlay) 1919 '(font-lock-face comint-highlight-prompt)))
1918 (overlay-end comint-last-prompt-overlay) 1920 ;; Reset comint-last-prompt so later on comint-output-filter does
1919 (overlay-properties comint-last-prompt-overlay)))))) 1921 ;; not remove the font-lock-face text property of the previous
1922 ;; (this) prompt.
1923 (setq comint-last-prompt nil)))
1920 1924
1921(defun comint-carriage-motion (start end) 1925(defun comint-carriage-motion (start end)
1922 "Interpret carriage control characters in the region from START to END. 1926 "Interpret carriage control characters in the region from START to END.
@@ -2063,20 +2067,15 @@ Make backspaces delete the previous character."
2063 (add-text-properties 2067 (add-text-properties
2064 prompt-start (point) 2068 prompt-start (point)
2065 '(read-only t rear-nonsticky t front-sticky (read-only))))) 2069 '(read-only t rear-nonsticky t front-sticky (read-only)))))
2066 (unless (and (bolp) (null comint-last-prompt-overlay)) 2070 (when comint-last-prompt
2067 ;; Need to create or move the prompt overlay (in the case 2071 (remove-text-properties (car comint-last-prompt)
2068 ;; where there is no prompt ((bolp) == t), we still do 2072 (cdr comint-last-prompt)
2069 ;; this if there's already an existing overlay). 2073 '(font-lock-face)))
2070 (if comint-last-prompt-overlay 2074 (setq comint-last-prompt
2071 ;; Just move an existing overlay 2075 (cons (copy-marker prompt-start) (point-marker)))
2072 (move-overlay comint-last-prompt-overlay 2076 (add-text-properties (car comint-last-prompt)
2073 prompt-start (point)) 2077 (cdr comint-last-prompt)
2074 ;; Need to create the overlay 2078 '(font-lock-face comint-highlight-prompt)))
2075 (setq comint-last-prompt-overlay
2076 (make-overlay prompt-start (point)))
2077 (overlay-put comint-last-prompt-overlay
2078 'font-lock-face 'comint-highlight-prompt))))
2079
2080 (goto-char saved-point))))))) 2079 (goto-char saved-point)))))))
2081 2080
2082(defun comint-preinput-scroll-to-bottom () 2081(defun comint-preinput-scroll-to-bottom ()
@@ -2296,7 +2295,7 @@ Security bug: your string can still be temporarily recovered with
2296 (interactive "P") ; Defeat snooping via C-x ESC ESC 2295 (interactive "P") ; Defeat snooping via C-x ESC ESC
2297 (let ((proc (get-buffer-process (current-buffer))) 2296 (let ((proc (get-buffer-process (current-buffer)))
2298 (prefix 2297 (prefix
2299 (if (eq (window-buffer (selected-window)) (current-buffer)) 2298 (if (eq (window-buffer) (current-buffer))
2300 "" 2299 ""
2301 (format "(In buffer %s) " 2300 (format "(In buffer %s) "
2302 (current-buffer))))) 2301 (current-buffer)))))
@@ -3108,7 +3107,7 @@ completions listing is dependent on the value of `comint-completion-autolist'.
3108Returns t if successful." 3107Returns t if successful."
3109 (interactive) 3108 (interactive)
3110 (when (comint--match-partial-filename) 3109 (when (comint--match-partial-filename)
3111 (unless (window-minibuffer-p (selected-window)) 3110 (unless (window-minibuffer-p)
3112 (message "Completing file name...")) 3111 (message "Completing file name..."))
3113 (let ((data (comint--complete-file-name-data))) 3112 (let ((data (comint--complete-file-name-data)))
3114 (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data))))) 3113 (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data)))))
@@ -3211,7 +3210,7 @@ Return `listed' if a completion listing was shown.
3211See also `comint-dynamic-complete-filename'." 3210See also `comint-dynamic-complete-filename'."
3212 (declare (obsolete completion-in-region "24.1")) 3211 (declare (obsolete completion-in-region "24.1"))
3213 (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin))) 3212 (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin)))
3214 (minibuffer-p (window-minibuffer-p (selected-window))) 3213 (minibuffer-p (window-minibuffer-p))
3215 (suffix (cond ((not comint-completion-addsuffix) "") 3214 (suffix (cond ((not comint-completion-addsuffix) "")
3216 ((not (consp comint-completion-addsuffix)) " ") 3215 ((not (consp comint-completion-addsuffix)) " ")
3217 (t (cdr comint-completion-addsuffix)))) 3216 (t (cdr comint-completion-addsuffix))))
@@ -3308,7 +3307,7 @@ Typing SPC flushes the completions buffer."
3308 (current-window-configuration)) 3307 (current-window-configuration))
3309 (with-output-to-temp-buffer "*Completions*" 3308 (with-output-to-temp-buffer "*Completions*"
3310 (display-completion-list completions common-substring)) 3309 (display-completion-list completions common-substring))
3311 (if (window-minibuffer-p (selected-window)) 3310 (if (window-minibuffer-p)
3312 (minibuffer-message "Type space to flush; repeat completion command to scroll") 3311 (minibuffer-message "Type space to flush; repeat completion command to scroll")
3313 (message "Type space to flush; repeat completion command to scroll"))) 3312 (message "Type space to flush; repeat completion command to scroll")))
3314 3313