GNU bug report logs -
#19710
24.4.51; Isearch is broken in comints which relly on regexp
Previous Next
Reported by: Vitalie Spinu <spinuvit <at> gmail.com>
Date: Wed, 28 Jan 2015 09:11:02 UTC
Severity: normal
Found in version 24.4.51
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19710 in the body.
You can then email your comments to 19710 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Wed, 28 Jan 2015 09:11:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Vitalie Spinu <spinuvit <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 28 Jan 2015 09:11:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
Vitalie
-----
In GNU Emacs 24.4.51.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
of 2015-01-28 on galago
Repository revision: 9664defd262252faf037c5fe1ea095f1cc4b308b
Windowing system distributor `The X.Org Foundation', version 11.0.11600000
System Description: Ubuntu 14.10
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Thu, 29 Jan 2015 01:03:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 19710 <at> debbugs.gnu.org (full text, mbox):
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Thu, 29 Jan 2015 08:14:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 19710 <at> debbugs.gnu.org (full text, mbox):
Thanks Juri, this patch solves the problem indeed.
Vitalie
>>> Juri Linkov on Thu, 29 Jan 2015 02:50:33 +0200 wrote:
>> 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.
Reply sent
to
Juri Linkov <juri <at> linkov.net>
:
You have taken responsibility.
(Thu, 05 Feb 2015 01:05:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Vitalie Spinu <spinuvit <at> gmail.com>
:
bug acknowledged by developer.
(Thu, 05 Feb 2015 01:05:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 19710-done <at> debbugs.gnu.org (full text, mbox):
> >> 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:
>
> Thanks Juri, this patch solves the problem indeed.
I fixed this on the emacs-24 branch because bug#19572 backported
previous changes to emacs-24.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Thu, 05 Feb 2015 10:04:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 19710-done <at> debbugs.gnu.org (full text, mbox):
Thanks. It works.
Vitalie
>>> Juri Linkov on Thu, 05 Feb 2015 02:57:07 +0200 wrote:
>> >> 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:
>>
>> Thanks Juri, this patch solves the problem indeed.
> I fixed this on the emacs-24 branch because bug#19572 backported
> previous changes to emacs-24.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Tue, 10 Feb 2015 00:40:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 19710 <at> debbugs.gnu.org (full text, mbox):
> Thanks. It works.
I noticed that it works differently when typing RET while point is
on the prompt, so I had to add support for this case for the users
who might want to do such a strange thing.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Wed, 18 Feb 2015 15:56:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 19710 <at> debbugs.gnu.org (full text, mbox):
Relatedly, comint-bol inside multiline output regions is broken.
In shell buffer:
$ locate pwd
then go to a previous line and M-x comint-bol. It will jump all the way
back to comint-prompt-regexp.
Vitalie
>>> Juri Linkov on Tue, 10 Feb 2015 02:39:08 +0200 wrote:
>> Thanks. It works.
> I noticed that it works differently when typing RET while point is
> on the prompt, so I had to add support for this case for the users
> who might want to do such a strange thing.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Wed, 18 Feb 2015 17:06:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 19710 <at> debbugs.gnu.org (full text, mbox):
> Relatedly, comint-bol inside multiline output regions is broken.
>
> In shell buffer:
>
> $ locate pwd
>
> then go to a previous line and M-x comint-bol. It will jump all the way
> back to comint-prompt-regexp.
The following patch for the emacs-24 branch should fix this regression.
It distinguishes two cases: when point is on the output or input
depending on the field property, for the case of comint-use-prompt-regexp=nil.
This means that we can't support multi-line commands for the case
when comint-use-prompt-regexp=t because it doesn't use fields, thus
there is no way to distinguish input from output.
So for comint-use-prompt-regexp=t `M-x comint-bol' will work
as in the previous release, but `M-x comint-bol' will be
fixed for comint-use-prompt-regexp=nil:
diff --git a/lisp/comint.el b/lisp/comint.el
index c81551a..2532dd7 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2267,8 +2267,6 @@ (defun comint-line-beginning-position ()
;; Use comint-prompt-regexp
(save-excursion
(beginning-of-line)
- (unless (looking-at comint-prompt-regexp)
- (re-search-backward comint-prompt-regexp nil t))
(comint-skip-prompt)
(point))
;; Use input fields. Note that, unlike the behavior of
@@ -2278,7 +2276,10 @@ (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 (field-beginning) (line-end-position))))
+ (constrain-to-field (if (eq (field-at-pos (point)) 'output)
+ (line-beginning-position)
+ (field-beginning))
+ (line-end-position))))
(defun comint-bol (&optional arg)
"Go to the beginning of line, then skip past the prompt, if any.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Wed, 18 Feb 2015 17:47:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 19710 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Date: Wed, 18 Feb 2015 19:01:52 +0200
> Cc: 19710 <at> debbugs.gnu.org
>
> > Relatedly, comint-bol inside multiline output regions is broken.
> >
> > In shell buffer:
> >
> > $ locate pwd
> >
> > then go to a previous line and M-x comint-bol. It will jump all the way
> > back to comint-prompt-regexp.
>
> The following patch for the emacs-24 branch should fix this regression.
If this a regression wrt 24.4?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Wed, 18 Feb 2015 18:19:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 19710 <at> debbugs.gnu.org (full text, mbox):
Works. Thanks!
>>> Juri Linkov on Wed, 18 Feb 2015 19:01:52 +0200 wrote:
>> Relatedly, comint-bol inside multiline output regions is broken.
>>
>> In shell buffer:
>>
>> $ locate pwd
>>
>> then go to a previous line and M-x comint-bol. It will jump all the way
>> back to comint-prompt-regexp.
> The following patch for the emacs-24 branch should fix this regression.
> It distinguishes two cases: when point is on the output or input
> depending on the field property, for the case of comint-use-prompt-regexp=nil.
> This means that we can't support multi-line commands for the case
> when comint-use-prompt-regexp=t because it doesn't use fields, thus
> there is no way to distinguish input from output.
> So for comint-use-prompt-regexp=t `M-x comint-bol' will work
> as in the previous release, but `M-x comint-bol' will be
> fixed for comint-use-prompt-regexp=nil:
> diff --git a/lisp/comint.el b/lisp/comint.el
> index c81551a..2532dd7 100644
> --- a/lisp/comint.el
> +++ b/lisp/comint.el
> @@ -2267,8 +2267,6 @@ (defun comint-line-beginning-position ()
> ;; Use comint-prompt-regexp
> (save-excursion
> (beginning-of-line)
> - (unless (looking-at comint-prompt-regexp)
> - (re-search-backward comint-prompt-regexp nil t))
> (comint-skip-prompt)
> (point))
> ;; Use input fields. Note that, unlike the behavior of
> @@ -2278,7 +2276,10 @@ (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 (field-beginning) (line-end-position))))
> + (constrain-to-field (if (eq (field-at-pos (point)) 'output)
> + (line-beginning-position)
> + (field-beginning))
> + (line-end-position))))
> (defun comint-bol (&optional arg)
> "Go to the beginning of line, then skip past the prompt, if any.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19710
; Package
emacs
.
(Wed, 18 Feb 2015 18:26:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 19710 <at> debbugs.gnu.org (full text, mbox):
>> > Relatedly, comint-bol inside multiline output regions is broken.
>> >
>> > In shell buffer:
>> >
>> > $ locate pwd
>> >
>> > then go to a previous line and M-x comint-bol. It will jump all the way
>> > back to comint-prompt-regexp.
>>
>> The following patch for the emacs-24 branch should fix this regression.
>
> If this a regression wrt 24.4?
Yes, it's a regression wrt 24.4 introduced a month ago.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 19 Mar 2015 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 156 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.