From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: killing the result of isearch Date: Tue, 7 Nov 2017 21:27:21 -0700 Message-ID: <20171107200447776721692@bob.proulx.com> References: <433bd3d0-a506-4d89-9d10-dcbfb0e23be0@default> <852BAA28-2A50-4AD9-B8D6-9F06905A4395@gmail.com> <20171107132316472375613@bob.proulx.com> 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 1510115290 12271 195.159.176.226 (8 Nov 2017 04:28:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 8 Nov 2017 04:28:10 +0000 (UTC) User-Agent: NeoMutt/20170609 (1.8.3) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 08 05:28:04 2017 Return-path: Envelope-to: geh-help-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 1eCHy7-0002ub-L9 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Nov 2017 05:28:03 +0100 Original-Received: from localhost ([::1]:57245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCHyE-0003nJ-UI for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Nov 2017 23:28:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCHxX-0003lX-13 for help-gnu-emacs@gnu.org; Tue, 07 Nov 2017 23:27:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCHxT-0005y2-2T for help-gnu-emacs@gnu.org; Tue, 07 Nov 2017 23:27:27 -0500 Original-Received: from havoc.proulx.com ([96.88.95.61]:40183) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCHxS-0005xh-R9 for help-gnu-emacs@gnu.org; Tue, 07 Nov 2017 23:27:23 -0500 Original-Received: from joseki.proulx.com (localhost [127.0.0.1]) by havoc.proulx.com (Postfix) with ESMTP id 899576C3 for ; Tue, 7 Nov 2017 21:27:21 -0700 (MST) Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 5167F217E5 for ; Tue, 7 Nov 2017 21:27:21 -0700 (MST) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id 2C4162DC5E; Tue, 7 Nov 2017 21:27:21 -0700 (MST) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 96.88.95.61 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114806 Archived-At: Jean-Christophe Helary wrote: > I've tried again the default behavior in the editor where I usually > do my regex search/replaces (BBEdit) and the only (and major) I have never used BBEdit and therefore am at a disadvantage in comparing behaviors. But perhaps someone else will have used it and have suggestions. > difference is where the mark is put at the beginning of the > search. In emacs it is put where the point is at the beginning of > the search, in BBEdit it is put at the beginning of the match, so > the region "matches" the search match. Yes. A fundamental difference. But wasn't that one of the advantagess of Isearch+? I recall Drew and another saying that the additional Isearch+ functionality included the ability to set the mark around the matched text. In this case it would leave the mark at the start of the match and the point at the end of the match which would create the region between and be exactly what you are saying you are wanting. You might give Isearch+ a try and report back with your experiences with it. > Now, I'm not going to argue about which is best, because the designs > are different, as Stephan wrote, search in emacs finds a location > and allows the user to act on that location while finding the match > is not the purpose but just the means to accomplish that, while in > BBEdit finding the match is the purpose of the function. Right. They started from different starting points and ended up at different ending points and we the users are seeing the tools available and selecting the best one from the set from our perspective. Just different. But emacs can be customized to work the way you want. > > The answers suggesting M-% are excellent suggestions. >=20 > Not really, because if I know what kind of regex I'm looking for, I > don't always know how I want to change the match, that depends on > context, and overwriting a selection is very often more efficient > than going through a replace hoop. I think here there is a misunderstanding. "C-s party M-% RET" will search for "party" and then delete it. Start by searching. In this case it is an interactive search and therefore you get feedback and interactively react to it. Then if you decide to delete the matching string at that moment type M-% RET from *within* an isearch will replace the matched text with nothing. This is different and separate from M-% standalone *outside* of an isearch. Outside of it you are right that you don't know what you will see yet and don't know what you might decide after you see it. But within an isearch you will see what is being matched and might decide to delete it and one way is to use M-% at that moment which will preload the previous search string into the match. I'm being very tedious and explicit here because I feel that this particular part might have been missed in the previous discussion. Went up the hill to fetch a pail of water. C-s SPC of SPC water M-% RET . Went up the hill to fetch a pail. This contains some subtle points of isearch. Let me break that apart. C-s SPC of SPC water Start an incremental search. Type in the string I want to match. Stay in incremental search and type in M-%. The details can be found in the documentation. https://www.gnu.org/software/emacs/manual/html_node/emacs/Special-Isear= ch.html#Special-Isearch While the incremental search is active type in M-% (which the easy keystrokes for me are ESC Shift-%). From the manual: Typing =E2=80=98M-%=E2=80=99 in incremental search invokes =E2=80=98= query-replace=E2=80=99 or =E2=80=98query-replace-regexp=E2=80=99 (depending on search mode) wit= h the current search string used as the string to replace. A negative prefix argum= ent means to replace backward. *Note Query Replace::. Typing "C-s SPC of SPC water" followed by M-% executes this query-replace from within isearch and preloads the search pattern prompting you for the replacement pattern. RET without entering a replacement sets it to empty effectively deleting it. Then you are in interactive query replace mode. Query replace is documented: https://www.gnu.org/software/emacs/manual/html_node/emacs/Query-Replace= .html#Query-Replace The most natural thing would be to hit SPC to make the replacement in the incremental search. Then if there are more occurrences further down it will proceed through all further occurrences. But if you don't want to replace anything further down the file, want to replace just that one thing and stop, then '.' is the best way. =E2=80=98. (Period)=E2=80=99 to replace this occurrence and then exit without searching for m= ore occurrences. Therefore my trace above is using '.' to replace just that one occurrence and then stop. Hope this helps! :-) Bob