Better multi-line input support in comint.el
Revert the change of comint-line-beginning-position callers, and modify comint-line-beginning-position instead. * lisp/comint.el (comint-history-isearch-search) (comint-history-isearch-message, comint-history-isearch-wrap): Use comint-line-beginning-position instead of field-beginning. (comint-send-input): Use either end-of-line or field-end depending on comint-use-prompt-regexp. (comint-line-beginning-position): Search backward for comint-prompt-regexp if comint-use-prompt-regexp is non-nil. Use field-beginning instead of line-beginning-position if comint-use-prompt-regexp is nil. Fixes: debbugs:19710
This commit is contained in:
parent
008a04ac9a
commit
a323b93d46
2 changed files with 29 additions and 10 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2015-02-05 Juri Linkov <juri@linkov.net>
|
||||||
|
|
||||||
|
Revert the previous change of comint-line-beginning-position callers,
|
||||||
|
and modify comint-line-beginning-position instead.
|
||||||
|
|
||||||
|
* comint.el (comint-history-isearch-search)
|
||||||
|
(comint-history-isearch-message, comint-history-isearch-wrap):
|
||||||
|
Use comint-line-beginning-position instead of field-beginning.
|
||||||
|
(comint-send-input): Use either end-of-line or field-end
|
||||||
|
depending on comint-use-prompt-regexp.
|
||||||
|
(comint-line-beginning-position): Search backward
|
||||||
|
for comint-prompt-regexp if comint-use-prompt-regexp is non-nil.
|
||||||
|
Use field-beginning instead of line-beginning-position
|
||||||
|
if comint-use-prompt-regexp is nil. (Bug#19710)
|
||||||
|
|
||||||
2015-02-04 Robert Pluim <rpluim@gmail.com> (tiny change)
|
2015-02-04 Robert Pluim <rpluim@gmail.com> (tiny change)
|
||||||
|
|
||||||
* calendar/todo-mode.el (todo-item-done): When done items are
|
* calendar/todo-mode.el (todo-item-done): When done items are
|
||||||
|
|
|
@ -1475,7 +1475,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'."
|
||||||
(or
|
(or
|
||||||
;; 1. First try searching in the initial comint text
|
;; 1. First try searching in the initial comint text
|
||||||
(funcall search-fun string
|
(funcall search-fun string
|
||||||
(if isearch-forward bound (field-beginning))
|
(if isearch-forward bound (comint-line-beginning-position))
|
||||||
noerror)
|
noerror)
|
||||||
;; 2. If the above search fails, start putting next/prev history
|
;; 2. If the above search fails, start putting next/prev history
|
||||||
;; elements in the comint successively, and search the string
|
;; elements in the comint successively, and search the string
|
||||||
|
@ -1491,7 +1491,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'."
|
||||||
(when (null comint-input-ring-index)
|
(when (null comint-input-ring-index)
|
||||||
(error "End of history; no next item"))
|
(error "End of history; no next item"))
|
||||||
(comint-next-input 1)
|
(comint-next-input 1)
|
||||||
(goto-char (field-beginning)))
|
(goto-char (comint-line-beginning-position)))
|
||||||
(t
|
(t
|
||||||
;; Signal an error here explicitly, because
|
;; Signal an error here explicitly, because
|
||||||
;; `comint-previous-input' doesn't signal an error.
|
;; `comint-previous-input' doesn't signal an error.
|
||||||
|
@ -1509,7 +1509,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'."
|
||||||
(unless isearch-forward
|
(unless isearch-forward
|
||||||
;; For backward search, don't search
|
;; For backward search, don't search
|
||||||
;; in the comint prompt
|
;; in the comint prompt
|
||||||
(field-beginning))
|
(comint-line-beginning-position))
|
||||||
noerror)))
|
noerror)))
|
||||||
;; Return point of the new search result
|
;; Return point of the new search result
|
||||||
(point))
|
(point))
|
||||||
|
@ -1533,16 +1533,16 @@ the function `isearch-message'."
|
||||||
(if (overlayp comint-history-isearch-message-overlay)
|
(if (overlayp comint-history-isearch-message-overlay)
|
||||||
(move-overlay comint-history-isearch-message-overlay
|
(move-overlay comint-history-isearch-message-overlay
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (field-beginning))
|
(goto-char (comint-line-beginning-position))
|
||||||
(forward-line 0)
|
(forward-line 0)
|
||||||
(point))
|
(point))
|
||||||
(field-beginning))
|
(comint-line-beginning-position))
|
||||||
(setq comint-history-isearch-message-overlay
|
(setq comint-history-isearch-message-overlay
|
||||||
(make-overlay (save-excursion
|
(make-overlay (save-excursion
|
||||||
(goto-char (field-beginning))
|
(goto-char (comint-line-beginning-position))
|
||||||
(forward-line 0)
|
(forward-line 0)
|
||||||
(point))
|
(point))
|
||||||
(field-beginning)))
|
(comint-line-beginning-position)))
|
||||||
(overlay-put comint-history-isearch-message-overlay 'evaporate t))
|
(overlay-put comint-history-isearch-message-overlay 'evaporate t))
|
||||||
(overlay-put comint-history-isearch-message-overlay
|
(overlay-put comint-history-isearch-message-overlay
|
||||||
'display (isearch-message-prefix ellipsis isearch-nonincremental))
|
'display (isearch-message-prefix ellipsis isearch-nonincremental))
|
||||||
|
@ -1563,7 +1563,7 @@ or to the last history element for a backward search."
|
||||||
(comint-goto-input (1- (ring-length comint-input-ring)))
|
(comint-goto-input (1- (ring-length comint-input-ring)))
|
||||||
(comint-goto-input nil))
|
(comint-goto-input nil))
|
||||||
(setq isearch-success t)
|
(setq isearch-success t)
|
||||||
(goto-char (if isearch-forward (field-beginning) (point-max))))
|
(goto-char (if isearch-forward (comint-line-beginning-position) (point-max))))
|
||||||
|
|
||||||
(defun comint-history-isearch-push-state ()
|
(defun comint-history-isearch-push-state ()
|
||||||
"Save a function restoring the state of input history search.
|
"Save a function restoring the state of input history search.
|
||||||
|
@ -1781,7 +1781,10 @@ Similarly for Soar, Scheme, etc."
|
||||||
(widen)
|
(widen)
|
||||||
(let* ((pmark (process-mark proc))
|
(let* ((pmark (process-mark proc))
|
||||||
(intxt (if (>= (point) (marker-position pmark))
|
(intxt (if (>= (point) (marker-position pmark))
|
||||||
(progn (if comint-eol-on-send (goto-char (field-end)))
|
(progn (if comint-eol-on-send
|
||||||
|
(if comint-use-prompt-regexp
|
||||||
|
(end-of-line)
|
||||||
|
(goto-char (field-end))))
|
||||||
(buffer-substring pmark (point)))
|
(buffer-substring pmark (point)))
|
||||||
(let ((copy (funcall comint-get-old-input)))
|
(let ((copy (funcall comint-get-old-input)))
|
||||||
(goto-char pmark)
|
(goto-char pmark)
|
||||||
|
@ -2260,6 +2263,7 @@ a buffer local variable."
|
||||||
(if comint-use-prompt-regexp
|
(if comint-use-prompt-regexp
|
||||||
;; Use comint-prompt-regexp
|
;; Use comint-prompt-regexp
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
(re-search-backward comint-prompt-regexp nil t)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(comint-skip-prompt)
|
(comint-skip-prompt)
|
||||||
(point))
|
(point))
|
||||||
|
@ -2270,7 +2274,7 @@ a buffer local variable."
|
||||||
;; if there are two fields on a line, then the first one is the
|
;; if there are two fields on a line, then the first one is the
|
||||||
;; prompt, and the second one is an input field, and is front-sticky
|
;; prompt, and the second one is an input field, and is front-sticky
|
||||||
;; (as input fields should be).
|
;; (as input fields should be).
|
||||||
(constrain-to-field (line-beginning-position) (line-end-position))))
|
(constrain-to-field (field-beginning) (line-end-position))))
|
||||||
|
|
||||||
(defun comint-bol (&optional arg)
|
(defun comint-bol (&optional arg)
|
||||||
"Go to the beginning of line, then skip past the prompt, if any.
|
"Go to the beginning of line, then skip past the prompt, if any.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue