From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Simple isearch concerns Date: Fri, 07 May 2021 20:14:52 +0300 Organization: LINKOV.NET Message-ID: <875yzumpur.fsf@mail.linkov.net> References: <20210403001539.x4rb55dvh46rmhb3.ref@Ergus> <87eefrbo9k.fsf@posteo.net> <7473b27b2b479f5686af@heytings.org> <87tuon9vf1.fsf@posteo.net> <20210403174508.xwr5uc36dzityitn@Ergus> <87wnsurdr7.fsf@gmail.com> <87fszij6to.fsf@mail.linkov.net> <87v98asulc.fsf@gmail.com> <87pmyimiwd.fsf@mail.linkov.net> <87bla11u5q.fsf@gmail.com> <87lf937hgk.fsf@mail.linkov.net> <87y2d1ksga.fsf@mail.linkov.net> <87r1it7zfw.fsf@gmail.com> <87v98466it.fsf@mail.linkov.net> <87bl9wcksv.fsf@gmail.com> <87tunnzqci.fsf@mail.linkov.net> <87bl9tmzun.fsf@gmail.com> <87y2cwhiti.fsf@mail.linkov.net> <87h7jk75b7.fsf@gmail.com> <87k0ofyd4p.fsf@mail.linkov.net> <875yzwq4x7.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19358"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Philip Kaludercic , Gregory Heytings , Ergus , Manuel Uberti , emacs-devel@gnu.org To: Augusto Stoffel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 07 19:19:17 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lf48C-0004uv-Ji for ged-emacs-devel@m.gmane-mx.org; Fri, 07 May 2021 19:19:16 +0200 Original-Received: from localhost ([::1]:50508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf48B-000315-Ec for ged-emacs-devel@m.gmane-mx.org; Fri, 07 May 2021 13:19:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf44W-0000da-Ua for emacs-devel@gnu.org; Fri, 07 May 2021 13:15:34 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:46725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf44P-0004Ez-0R for emacs-devel@gnu.org; Fri, 07 May 2021 13:15:28 -0400 X-Originating-IP: 91.129.102.166 Original-Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 0FF49E0004; Fri, 7 May 2021 17:15:15 +0000 (UTC) In-Reply-To: <875yzwq4x7.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 05 May 2021 23:52:36 +0300") Received-SPF: pass client-ip=217.70.183.196; envelope-from=juri@linkov.net; helo=relay4-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269008 Archived-At: --=-=-= Content-Type: text/plain > The current design is not without flaws either: when multi-buffer > isearch visits another buffer, it removes the isearch menu, because > isearch-mode is already buffer-local. This patch fixes the problem. It disables isearch-mode in the previous buffer, and enables in the next buffer. Later for isearch-buffer-local, the same function could remove hooks in the previous buffer, and add buffer-local hooks in the next buffer. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=multi-isearch-switch-buffer.patch diff --git a/lisp/isearch.el b/lisp/isearch.el index 5c71519054..095f8ba145 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -3549,9 +3552,8 @@ isearch-search-string (when pos1 ;; When using multiple buffers isearch, switch to the new buffer here, ;; because `save-excursion' above doesn't allow doing it inside funcall. - (if (and multi-isearch-next-buffer-current-function - (buffer-live-p multi-isearch-current-buffer)) - (switch-to-buffer multi-isearch-current-buffer)) + (when multi-isearch-next-buffer-current-function + (multi-isearch-switch-buffer)) (goto-char pos1) pos1))) diff --git a/lisp/misearch.el b/lisp/misearch.el index 335efb9516..338880f25f 100644 --- a/lisp/misearch.el +++ b/lisp/misearch.el @@ -190,10 +190,10 @@ multi-isearch-wrap (if (or (null multi-isearch-pause) (and multi-isearch-pause multi-isearch-current-buffer)) (progn - (switch-to-buffer - (setq multi-isearch-current-buffer - (funcall multi-isearch-next-buffer-current-function - (current-buffer) t))) + (setq multi-isearch-current-buffer + (funcall multi-isearch-next-buffer-current-function + (current-buffer) t)) + (multi-isearch-switch-buffer) (goto-char (if isearch-forward (point-min) (point-max)))) (setq multi-isearch-current-buffer (current-buffer)) (setq isearch-wrapped nil))) @@ -208,8 +208,18 @@ multi-isearch-push-state (defun multi-isearch-pop-state (_cmd buffer) "Restore the multiple buffers search state in BUFFER. Switch to the buffer restored from the search status stack." - (unless (equal buffer (current-buffer)) - (switch-to-buffer (setq multi-isearch-current-buffer buffer)))) + (unless (eq buffer (current-buffer)) + (setq multi-isearch-current-buffer buffer) + (multi-isearch-switch-buffer))) + +;;;###autoload +(defun multi-isearch-switch-buffer () + "Switch to the next buffer in multi-buffer search." + (when (and (buffer-live-p multi-isearch-current-buffer) + (not (eq multi-isearch-current-buffer (current-buffer)))) + (setq isearch-mode nil) + (switch-to-buffer multi-isearch-current-buffer) + (setq isearch-mode " M-Isearch"))) ;;; Global multi-buffer search invocations --=-=-=--