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: [WIP PATCH] Controlling Isearch from the minibuffer Date: Wed, 12 May 2021 20:13:03 +0300 Organization: LINKOV.NET Message-ID: <87cztvx4dc.fsf@mail.linkov.net> References: <87zgx5cz33.fsf@gmail.com> <87o8djohqf.fsf@mail.linkov.net> <87eeeenxqq.fsf@gmail.com> <87h7jath3m.fsf@mail.linkov.net> <87mtt0wj37.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20175"; 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: emacs-devel@gnu.org To: Augusto Stoffel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 12 19:36:22 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 1lgsmU-00058l-K6 for ged-emacs-devel@m.gmane-mx.org; Wed, 12 May 2021 19:36:22 +0200 Original-Received: from localhost ([::1]:44484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgsmT-0006Sz-M5 for ged-emacs-devel@m.gmane-mx.org; Wed, 12 May 2021 13:36:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgsUl-0007je-SX for emacs-devel@gnu.org; Wed, 12 May 2021 13:18:03 -0400 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:34583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgsUj-0008Rt-8W for emacs-devel@gnu.org; Wed, 12 May 2021 13:18:03 -0400 Original-Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 15EFC240003; Wed, 12 May 2021 17:17:54 +0000 (UTC) In-Reply-To: <87mtt0wj37.fsf@gmail.com> (Augusto Stoffel's message of "Wed, 12 May 2021 08:40:28 +0200") Received-SPF: pass client-ip=217.70.178.230; envelope-from=juri@linkov.net; helo=relay10.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:269217 Archived-At: >>>> You can avoid the timer hack by adding a guard to >>>> isearch-post-command-hook: when at the end of the isearch command, >>>> point is not in the minibuffer, activate the minibuffer >>>> (assuming that isearch-from-minibuffer is t). >>> >>> That didn't work well, because when canceling a command called from the >>> post-command hook one gets an ugly error message. >> >> How do yo cancel such a command? > > C-g Do you mean the global C-g bound to keyboard-quit, isearch-mode's C-g bound to isearch-abort, or minibuffer's C-g bound to minibuffer-keyboard-quit? And what was the error message? > To put it from another perspective: you said earlier that my patch could > be boiled down to 10 lines. Well, adding lazy highlight/count to > `isearch-edit-string' is certainly more work than that. But once this > is in place, then yes, the minibuffer-controlled mode is a small > addition. Adding lazy highlight/count should not be more work. It's simple to do with a few lines by setting minibuffer-local isearch-message-function, the same way like minibuffer-history-isearch-setup sets it to minibuffer-history-isearch-message. >>> 2. A M-s prefix is added to minibuffer-local-isearch-map, as well as a >>> few extra commands (M->, M-<, etc.) >> >> The users might want to use M-< M-> to go to the beginning/end of the >> minibuffer. > > This seems way less useful than going to the first/last match in the > search buffer, since in the minibuffer C-a and C-e are usually > sufficient. > > By the way, what's the idea behind `minibuffer-beginning-of-buffer'? It > moves past the prompt, which is a useless point to go. It's useful when minibuffer-beginning-of-buffer-movement is customized to t. I don't know why currently its default is nil. > First of all, let me say that you suggestion to get rid of the > `with-isearch-window' macro works fine. The remaining problem is with > commands that create a minibuffer, and therefore require that we quit > the `isearch-edit-string' minibuffer first. One example would be > `isearch-query-replace'. > > So here's the the situation in more detail: > > - You are in an `isearch-edit-string' session > - Then you press M-% > - Now we are in the pre-command-hook. We check `this-command` and > see that it will need the minibuffer. > > From there, how can we get rid of the minibuffer and continue running > this-command? Calling `exit-minibuffer' now would return control to > whoever called `isearch-edit-string', so `this-command' would never run. This is an interesting problem. Would it be possible after calling exit-minibuffer to allow the caller of isearch-edit-string (mosy likely the caller should be isearch-mode when isearch-from-minibuffer is t) to call the right function after exiting from the minibuffer, e.g. when this-command-keys was M-% then call isearch-query-replace after isearch-edit-string at the end of isearch-mode.