From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#30187: M-e should restore isearch correctly in special modes Date: Mon, 29 Jan 2018 23:57:17 +0200 Organization: LINKOV.NET Message-ID: <87a7wwz5tu.fsf@mail.linkov.net> References: <87607wnsnb.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1517263179 3796 195.159.176.226 (29 Jan 2018 21:59:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Jan 2018 21:59:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: 30187@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 29 22:59:35 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egHSK-0007kj-HR for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Jan 2018 22:59:12 +0100 Original-Received: from localhost ([::1]:42739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egHUL-0006aT-Ee for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Jan 2018 17:01:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egHU9-0006ZH-3t for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 17:01:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egHU6-0006nO-DG for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 17:01:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40419) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egHU6-0006nI-A1 for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 17:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1egHU6-000078-2C for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 17:01: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: Mon, 29 Jan 2018 22:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30187 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30187-submit@debbugs.gnu.org id=B30187.1517263235392 (code B ref 30187); Mon, 29 Jan 2018 22:01:02 +0000 Original-Received: (at 30187) by debbugs.gnu.org; 29 Jan 2018 22:00:35 +0000 Original-Received: from localhost ([127.0.0.1]:48315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egHTf-00006F-0r for submit@debbugs.gnu.org; Mon, 29 Jan 2018 17:00:35 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:57674 helo=homiemail-a75.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egHTb-000066-VC for 30187@debbugs.gnu.org; Mon, 29 Jan 2018 17:00:32 -0500 Original-Received: from homiemail-a75.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a75.g.dreamhost.com (Postfix) with ESMTP id 7031A5EC07C for <30187@debbugs.gnu.org>; Mon, 29 Jan 2018 14:00:31 -0800 (PST) Original-Received: from localhost.linkov.net (m91-129-109-178.cust.tele2.ee [91.129.109.178]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a75.g.dreamhost.com (Postfix) with ESMTPSA id C89625EC072 for <30187@debbugs.gnu.org>; Mon, 29 Jan 2018 14:00:30 -0800 (PST) In-Reply-To: <87607wnsnb.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 20 Jan 2018 23:10:16 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:142667 Archived-At: > There was an old problem that =E2=80=98isearch-edit-string=E2=80=99 inc= orrectly > restored a previous isearch mode in such commands as > =E2=80=98comint-history-isearch-backward=E2=80=99 and =E2=80=98dired-is= earch-filenames=E2=80=99 > because they let-bind variables that affects the search parameters, > e.g. =E2=80=98(let ((dired-isearch-filenames t)))=E2=80=99 only at the = starting > isearch, but when =E2=80=98M-e=E2=80=99 (isearch-edit-string) exits ise= arch, > and later starts again, these let-binding are not in effect > and thus restore the wrong search state. There is another problem with =E2=80=98comint-history-isearch-backward=E2= =80=99: when it is called at the end of an =E2=80=9C*Async Shell Command*=E2=80=9D= buffer it should not activate comint-history isearch, only a normal isearch should be started. I tried different approaches, but only workable solution is to check whether the shell prompt is empty as it is in all =E2=80=9C*Async Shell Command*=E2=80=9D buffers: diff --git a/lisp/comint.el b/lisp/comint.el index 8dba317..b7179e2 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1448,10 +1448,17 @@ comint-history-isearch-message-overlay (defun comint-history-isearch-setup () "Set up a comint for using Isearch to search the input history. Intended to be added to `isearch-mode-hook' in `comint-mode'." - (when (or (eq comint-history-isearch t) - (and (eq comint-history-isearch 'dwim) - ;; Point is at command line. - (comint-after-pmark-p))) + (when (and (get-buffer-process (current-buffer)) + (or (eq comint-history-isearch t) + (and (eq comint-history-isearch 'dwim) + ;; Point is at command line. + (comint-after-pmark-p) + ;; Prompt is not empty like in Async Shell Command buffers + (not (eq (save-excursion + (goto-char (comint-line-beginning-position)) + (forward-line 0) + (point)) + (comint-line-beginning-position)))))) (setq isearch-message-prefix-add "history ") (setq-local isearch-search-fun-function #'comint-history-isearch-search)