diff options
| author | Juri Linkov | 2015-02-05 02:52:41 +0200 |
|---|---|---|
| committer | Juri Linkov | 2015-02-05 02:52:41 +0200 |
| commit | a323b93d466c403cbef96184d510b134549c7806 (patch) | |
| tree | 9f95858f7a61482860822351fd03db2e7c123c6c | |
| parent | 008a04ac9af20540d6e7ee4b61fb5bb3b21ef0e6 (diff) | |
| download | emacs-a323b93d466c403cbef96184d510b134549c7806.tar.gz emacs-a323b93d466c403cbef96184d510b134549c7806.zip | |
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
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/comint.el | 24 |
2 files changed, 29 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0e00cb2f17f..6c3caa826e8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2015-02-05 Juri Linkov <juri@linkov.net> | ||
| 2 | |||
| 3 | Revert the previous change of comint-line-beginning-position callers, | ||
| 4 | and modify comint-line-beginning-position instead. | ||
| 5 | |||
| 6 | * comint.el (comint-history-isearch-search) | ||
| 7 | (comint-history-isearch-message, comint-history-isearch-wrap): | ||
| 8 | Use comint-line-beginning-position instead of field-beginning. | ||
| 9 | (comint-send-input): Use either end-of-line or field-end | ||
| 10 | depending on comint-use-prompt-regexp. | ||
| 11 | (comint-line-beginning-position): Search backward | ||
| 12 | for comint-prompt-regexp if comint-use-prompt-regexp is non-nil. | ||
| 13 | Use field-beginning instead of line-beginning-position | ||
| 14 | if comint-use-prompt-regexp is nil. (Bug#19710) | ||
| 15 | |||
| 1 | 2015-02-04 Robert Pluim <rpluim@gmail.com> (tiny change) | 16 | 2015-02-04 Robert Pluim <rpluim@gmail.com> (tiny change) |
| 2 | 17 | ||
| 3 | * calendar/todo-mode.el (todo-item-done): When done items are | 18 | * calendar/todo-mode.el (todo-item-done): When done items are |
diff --git a/lisp/comint.el b/lisp/comint.el index f33034bdb57..419938ea684 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1475,7 +1475,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'." | |||
| 1475 | (or | 1475 | (or |
| 1476 | ;; 1. First try searching in the initial comint text | 1476 | ;; 1. First try searching in the initial comint text |
| 1477 | (funcall search-fun string | 1477 | (funcall search-fun string |
| 1478 | (if isearch-forward bound (field-beginning)) | 1478 | (if isearch-forward bound (comint-line-beginning-position)) |
| 1479 | noerror) | 1479 | noerror) |
| 1480 | ;; 2. If the above search fails, start putting next/prev history | 1480 | ;; 2. If the above search fails, start putting next/prev history |
| 1481 | ;; elements in the comint successively, and search the string | 1481 | ;; elements in the comint successively, and search the string |
| @@ -1491,7 +1491,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'." | |||
| 1491 | (when (null comint-input-ring-index) | 1491 | (when (null comint-input-ring-index) |
| 1492 | (error "End of history; no next item")) | 1492 | (error "End of history; no next item")) |
| 1493 | (comint-next-input 1) | 1493 | (comint-next-input 1) |
| 1494 | (goto-char (field-beginning))) | 1494 | (goto-char (comint-line-beginning-position))) |
| 1495 | (t | 1495 | (t |
| 1496 | ;; Signal an error here explicitly, because | 1496 | ;; Signal an error here explicitly, because |
| 1497 | ;; `comint-previous-input' doesn't signal an error. | 1497 | ;; `comint-previous-input' doesn't signal an error. |
| @@ -1509,7 +1509,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'." | |||
| 1509 | (unless isearch-forward | 1509 | (unless isearch-forward |
| 1510 | ;; For backward search, don't search | 1510 | ;; For backward search, don't search |
| 1511 | ;; in the comint prompt | 1511 | ;; in the comint prompt |
| 1512 | (field-beginning)) | 1512 | (comint-line-beginning-position)) |
| 1513 | noerror))) | 1513 | noerror))) |
| 1514 | ;; Return point of the new search result | 1514 | ;; Return point of the new search result |
| 1515 | (point)) | 1515 | (point)) |
| @@ -1533,16 +1533,16 @@ the function `isearch-message'." | |||
| 1533 | (if (overlayp comint-history-isearch-message-overlay) | 1533 | (if (overlayp comint-history-isearch-message-overlay) |
| 1534 | (move-overlay comint-history-isearch-message-overlay | 1534 | (move-overlay comint-history-isearch-message-overlay |
| 1535 | (save-excursion | 1535 | (save-excursion |
| 1536 | (goto-char (field-beginning)) | 1536 | (goto-char (comint-line-beginning-position)) |
| 1537 | (forward-line 0) | 1537 | (forward-line 0) |
| 1538 | (point)) | 1538 | (point)) |
| 1539 | (field-beginning)) | 1539 | (comint-line-beginning-position)) |
| 1540 | (setq comint-history-isearch-message-overlay | 1540 | (setq comint-history-isearch-message-overlay |
| 1541 | (make-overlay (save-excursion | 1541 | (make-overlay (save-excursion |
| 1542 | (goto-char (field-beginning)) | 1542 | (goto-char (comint-line-beginning-position)) |
| 1543 | (forward-line 0) | 1543 | (forward-line 0) |
| 1544 | (point)) | 1544 | (point)) |
| 1545 | (field-beginning))) | 1545 | (comint-line-beginning-position))) |
| 1546 | (overlay-put comint-history-isearch-message-overlay 'evaporate t)) | 1546 | (overlay-put comint-history-isearch-message-overlay 'evaporate t)) |
| 1547 | (overlay-put comint-history-isearch-message-overlay | 1547 | (overlay-put comint-history-isearch-message-overlay |
| 1548 | 'display (isearch-message-prefix ellipsis isearch-nonincremental)) | 1548 | 'display (isearch-message-prefix ellipsis isearch-nonincremental)) |
| @@ -1563,7 +1563,7 @@ or to the last history element for a backward search." | |||
| 1563 | (comint-goto-input (1- (ring-length comint-input-ring))) | 1563 | (comint-goto-input (1- (ring-length comint-input-ring))) |
| 1564 | (comint-goto-input nil)) | 1564 | (comint-goto-input nil)) |
| 1565 | (setq isearch-success t) | 1565 | (setq isearch-success t) |
| 1566 | (goto-char (if isearch-forward (field-beginning) (point-max)))) | 1566 | (goto-char (if isearch-forward (comint-line-beginning-position) (point-max)))) |
| 1567 | 1567 | ||
| 1568 | (defun comint-history-isearch-push-state () | 1568 | (defun comint-history-isearch-push-state () |
| 1569 | "Save a function restoring the state of input history search. | 1569 | "Save a function restoring the state of input history search. |
| @@ -1781,7 +1781,10 @@ Similarly for Soar, Scheme, etc." | |||
| 1781 | (widen) | 1781 | (widen) |
| 1782 | (let* ((pmark (process-mark proc)) | 1782 | (let* ((pmark (process-mark proc)) |
| 1783 | (intxt (if (>= (point) (marker-position pmark)) | 1783 | (intxt (if (>= (point) (marker-position pmark)) |
| 1784 | (progn (if comint-eol-on-send (goto-char (field-end))) | 1784 | (progn (if comint-eol-on-send |
| 1785 | (if comint-use-prompt-regexp | ||
| 1786 | (end-of-line) | ||
| 1787 | (goto-char (field-end)))) | ||
| 1785 | (buffer-substring pmark (point))) | 1788 | (buffer-substring pmark (point))) |
| 1786 | (let ((copy (funcall comint-get-old-input))) | 1789 | (let ((copy (funcall comint-get-old-input))) |
| 1787 | (goto-char pmark) | 1790 | (goto-char pmark) |
| @@ -2260,6 +2263,7 @@ a buffer local variable." | |||
| 2260 | (if comint-use-prompt-regexp | 2263 | (if comint-use-prompt-regexp |
| 2261 | ;; Use comint-prompt-regexp | 2264 | ;; Use comint-prompt-regexp |
| 2262 | (save-excursion | 2265 | (save-excursion |
| 2266 | (re-search-backward comint-prompt-regexp nil t) | ||
| 2263 | (beginning-of-line) | 2267 | (beginning-of-line) |
| 2264 | (comint-skip-prompt) | 2268 | (comint-skip-prompt) |
| 2265 | (point)) | 2269 | (point)) |
| @@ -2270,7 +2274,7 @@ a buffer local variable." | |||
| 2270 | ;; if there are two fields on a line, then the first one is the | 2274 | ;; if there are two fields on a line, then the first one is the |
| 2271 | ;; prompt, and the second one is an input field, and is front-sticky | 2275 | ;; prompt, and the second one is an input field, and is front-sticky |
| 2272 | ;; (as input fields should be). | 2276 | ;; (as input fields should be). |
| 2273 | (constrain-to-field (line-beginning-position) (line-end-position)))) | 2277 | (constrain-to-field (field-beginning) (line-end-position)))) |
| 2274 | 2278 | ||
| 2275 | (defun comint-bol (&optional arg) | 2279 | (defun comint-bol (&optional arg) |
| 2276 | "Go to the beginning of line, then skip past the prompt, if any. | 2280 | "Go to the beginning of line, then skip past the prompt, if any. |