From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#19710: 24.4.51; Isearch is broken in comints which relly on regexp Date: Thu, 29 Jan 2015 02:50:33 +0200 Organization: LINKOV.NET Message-ID: <874mrawgcu.fsf@mail.linkov.net> References: <87oapjmfth.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422493392 8577 80.91.229.3 (29 Jan 2015 01:03:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2015 01:03:12 +0000 (UTC) Cc: 19710@debbugs.gnu.org To: Vitalie Spinu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 29 02:03:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YGdVn-0001wS-3z for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Jan 2015 02:03:11 +0100 Original-Received: from localhost ([::1]:57209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGdVm-0003JZ-Cc for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Jan 2015 20:03:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGdVi-0003IV-F3 for bug-gnu-emacs@gnu.org; Wed, 28 Jan 2015 20:03:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGdVf-00025M-8m for bug-gnu-emacs@gnu.org; Wed, 28 Jan 2015 20:03:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGdVf-00025F-5B for bug-gnu-emacs@gnu.org; Wed, 28 Jan 2015 20:03:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YGdVe-0006wf-QY for bug-gnu-emacs@gnu.org; Wed, 28 Jan 2015 20:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Jan 2015 01:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19710 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19710-submit@debbugs.gnu.org id=B19710.142249333526644 (code B ref 19710); Thu, 29 Jan 2015 01:03:02 +0000 Original-Received: (at 19710) by debbugs.gnu.org; 29 Jan 2015 01:02:15 +0000 Original-Received: from localhost ([127.0.0.1]:56760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YGdUs-0006vf-Et for submit@debbugs.gnu.org; Wed, 28 Jan 2015 20:02:14 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.222.226]:51324 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YGdUo-0006vV-Jo for 19710@debbugs.gnu.org; Wed, 28 Jan 2015 20:02:11 -0500 Original-Received: from localhost.linkov.net (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 6905A362E859EF; Wed, 28 Jan 2015 17:02:08 -0800 (PST) In-Reply-To: <87oapjmfth.fsf@gmail.com> (Vitalie Spinu's message of "Wed, 28 Jan 2015 10:10:02 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98850 Archived-At: > 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.