summaryrefslogtreecommitdiff
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2012-07-02 12:18:02 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-07-02 12:18:02 -0400
commit2b5208f18115bd0f364c11cbdc8124878158927a (patch)
tree334c5215dd3be3f65c4b0bf1e997eda43ad457d8 /lisp/comint.el
parent3df31c9f8b4565f043ba56409ec8d1bc0c12a211 (diff)
downloademacs-2b5208f18115bd0f364c11cbdc8124878158927a.tar.gz
emacs-2b5208f18115bd0f364c11cbdc8124878158927a.tar.bz2
emacs-2b5208f18115bd0f364c11cbdc8124878158927a.zip
* lisp/comint.el (comint-output-filter): Filter out repeated prompts.
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index 122dc629564..4ccbfb5f9c8 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2006,6 +2006,20 @@ Make backspaces delete the previous character."
(goto-char (process-mark process))
(set-marker comint-last-output-start (point))
+ ;; Try to skip repeated prompts, which can occur as a result of
+ ;; commands sent without inserting them in the buffer.
+ (let ((bol (save-excursion (forward-line 0) (point)))) ;No fields.
+ (when (and (not (bolp))
+ (looking-back comint-prompt-regexp bol))
+ (let* ((prompt (buffer-substring bol (point)))
+ (prompt-re (concat "\\`" (regexp-quote prompt))))
+ (while (string-match prompt-re string)
+ (setq string (substring string (match-end 0)))))))
+ (while (string-match (concat "\\(^" comint-prompt-regexp
+ "\\)\\1+")
+ string)
+ (setq string (replace-match "\\1" nil nil string)))
+
;; insert-before-markers is a bad thing. XXX
;; Luckily we don't have to use it any more, we use
;; window-point-insertion-type instead.
@@ -2672,6 +2686,7 @@ prompts should stay at the beginning of a line. If this is not
the case, this command just calls `kill-region' with all
read-only properties intact. The read-only status of newlines is
updated using `comint-update-fence', if necessary."
+ (declare (advertised-calling-convention (beg end) "23.3"))
(interactive "r")
(save-excursion
(let* ((true-beg (min beg end))
@@ -2690,8 +2705,6 @@ updated using `comint-update-fence', if necessary."
(let ((inhibit-read-only t))
(kill-region beg end yank-handler)
(comint-update-fence))))))
-(set-advertised-calling-convention 'comint-kill-region '(beg end) "23.3")
-
;; Support for source-file processing commands.
;;============================================================================