From: Juri Linkov <juri@linkov.net>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: 19710@debbugs.gnu.org
Subject: bug#19710: 24.4.51; Isearch is broken in comints which relly on regexp
Date: Thu, 29 Jan 2015 02:50:33 +0200 [thread overview]
Message-ID: <874mrawgcu.fsf@mail.linkov.net> (raw)
In-Reply-To: <87oapjmfth.fsf@gmail.com> (Vitalie Spinu's message of "Wed, 28 Jan 2015 10:10:02 +0100")
> Recent changes to commit to allow for multiline search assume fields
> throughout. The common case when comint-use-prompt-regexp is non-nil is
> not captured.
>
> To see the problem start shell and issue a couple of commands. Then
> (setq comint-use-prompt-regexp t), and add a couple of RETs. Then try M-r.
>
> You should see "Regexp history I-search backward:" several lines above
> where it should be and isearch will not work as expected.
>
> If you restart your shell, you will not even see the "Regexp history
> I-search backward:" as there are no fields in the buffer.
Thanks for the report. This can be fixed by the patch that
reverts the change of callers, and instead modifies
`comint-line-beginning-position' to support multi-line input
for both cases of comint-use-prompt-regexp = t/nil:
diff --git a/lisp/comint.el b/lisp/comint.el
index 30c4dda..1333a0b 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1475,7 +1475,7 @@ (defun comint-history-isearch-search ()
(or
;; 1. First try searching in the initial comint text
(funcall search-fun string
- (if isearch-forward bound (field-beginning))
+ (if isearch-forward bound (comint-line-beginning-position))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the comint successively, and search the string
@@ -1491,7 +1491,7 @@ (defun comint-history-isearch-search ()
(when (null comint-input-ring-index)
(error "End of history; no next item"))
(comint-next-input 1)
- (goto-char (field-beginning)))
+ (goto-char (comint-line-beginning-position)))
(t
;; Signal an error here explicitly, because
;; `comint-previous-input' doesn't signal an error.
@@ -1509,7 +1509,7 @@ (defun comint-history-isearch-search ()
(unless isearch-forward
;; For backward search, don't search
;; in the comint prompt
- (field-beginning))
+ (comint-line-beginning-position))
noerror)))
;; Return point of the new search result
(point))
@@ -1533,16 +1533,16 @@ (defun comint-history-isearch-message (&optional c-q-hack ellipsis)
(if (overlayp comint-history-isearch-message-overlay)
(move-overlay comint-history-isearch-message-overlay
(save-excursion
- (goto-char (field-beginning))
+ (goto-char (comint-line-beginning-position))
(forward-line 0)
(point))
- (field-beginning))
+ (comint-line-beginning-position))
(setq comint-history-isearch-message-overlay
(make-overlay (save-excursion
- (goto-char (field-beginning))
+ (goto-char (comint-line-beginning-position))
(forward-line 0)
(point))
- (field-beginning)))
+ (comint-line-beginning-position)))
(overlay-put comint-history-isearch-message-overlay 'evaporate t))
(overlay-put comint-history-isearch-message-overlay
'display (isearch-message-prefix ellipsis isearch-nonincremental))
@@ -1563,7 +1563,7 @@ (defun comint-history-isearch-wrap ()
(comint-goto-input (1- (ring-length comint-input-ring)))
(comint-goto-input nil))
(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 ()
"Save a function restoring the state of input history search.
@@ -1787,7 +1787,10 @@ (defun comint-send-input (&optional no-newline artificial)
(widen)
(let* ((pmark (process-mark proc))
(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)))
(let ((copy (funcall comint-get-old-input)))
(goto-char pmark)
@@ -2266,6 +2269,7 @@ (defun comint-line-beginning-position ()
(if comint-use-prompt-regexp
;; Use comint-prompt-regexp
(save-excursion
+ (re-search-backward (concat comint-prompt-regexp ".*") nil t)
(beginning-of-line)
(comint-skip-prompt)
(point))
@@ -2276,7 +2280,7 @@ (defun comint-line-beginning-position ()
;; 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
;; (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)
"Go to the beginning of line, then skip past the prompt, if any.
next prev parent reply other threads:[~2015-01-29 0:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 9:10 bug#19710: 24.4.51; Isearch is broken in comints which relly on regexp Vitalie Spinu
2015-01-29 0:50 ` Juri Linkov [this message]
2015-01-29 8:13 ` Vitalie Spinu
2015-02-05 0:57 ` Juri Linkov
2015-02-05 10:03 ` Vitalie Spinu
2015-02-10 0:39 ` Juri Linkov
2015-02-18 15:55 ` Vitalie Spinu
2015-02-18 17:01 ` Juri Linkov
2015-02-18 17:46 ` Eli Zaretskii
2015-02-18 18:20 ` Juri Linkov
2015-02-18 18:18 ` Vitalie Spinu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874mrawgcu.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=19710@debbugs.gnu.org \
--cc=spinuvit@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).