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 15:53:17 -0700 Message-ID: <20171107151258910761350@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=us-ascii X-Trace: blaine.gmane.org 1510095233 1533 195.159.176.226 (7 Nov 2017 22:53:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Nov 2017 22:53:53 +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 Tue Nov 07 23:53:48 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 1eCCkd-0000AW-Lz for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Nov 2017 23:53:47 +0100 Original-Received: from localhost ([::1]:56217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCCkl-0003ge-4T for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Nov 2017 17:53:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCCkF-0003fd-PM for help-gnu-emacs@gnu.org; Tue, 07 Nov 2017 17:53:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCCkB-0002OO-Ol for help-gnu-emacs@gnu.org; Tue, 07 Nov 2017 17:53:23 -0500 Original-Received: from havoc.proulx.com ([96.88.95.61]:36733) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCCkB-0002Nd-Il for help-gnu-emacs@gnu.org; Tue, 07 Nov 2017 17:53:19 -0500 Original-Received: from joseki.proulx.com (localhost [127.0.0.1]) by havoc.proulx.com (Postfix) with ESMTP id 296A4212 for ; Tue, 7 Nov 2017 15:53:18 -0700 (MST) Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id E14C1217E4 for ; Tue, 7 Nov 2017 15:53:17 -0700 (MST) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id CAB2D2DC5E; Tue, 7 Nov 2017 15:53:17 -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:114798 Archived-At: Drew Adams wrote: > > Let's change "One-two, Buckle my shoe" to something else. > > C-s one-two, buckle my shoe C-r RET C-s C-s RET C-x C-x C-w > > (You don't need the `C-x C-x' here, unless you want to > see highlighted what `C-w' will delete.) True. But I always like the positive feedback about the region that will be deleted. So I am almost always using C-x C-x prior to region commands. Plus I was originally thinking of using DEL there and that needs the highlight to be active. In that case I needed C-x C-x to highlight the region so that DEL would delete it. > > Personally I always bind C-s to isearch-forward-regexp instead of > > leaving it at isearch-forward. Regular expressions are so much more > > powerful and useful. > > OK, but what you show above does not work, in general, > for regexps. Regexp search forward and backward do not > find the same text, generally. In the completely general case, true. But most of the time they will work fine. One: One, two, buckle shoe. C-s one.*shoe That will obviously match all of the way back to the "One:" part, undesirably, when search forward. But that doesn't invalidate the technique all of the time. I certainly wouldn't give up on regular expressions simply because not every regular expression can be used in every case. And in the above if you try it forward with C-s and see that it matches too much and then reverse direction with C-r one finds that it matched exactly what was desired with non-greedy matching. (I haven't ever dug into figuring out why.) But all along the way there is feedback as to what is happening. It isn't going to silently do something scary. I wouldn't avoid it. Because that would mean missing out on all of the capabilities of regular expressions. > If you regexp-search for the same text, `one-two, > buckle my shoe', no problem. But if you use `o.*oe' > you'll be in trouble. Using "o" trying to match for "one" and "oe" trying to match for "shoe" doesn't feel solid enough for me. Matching only one and two letters feels like it is asking to match something unexpected. I suggest putting enough text in there to anchor it firmly. Remembering that all of this is interacive editing, if it isn't doing what you want then take corrective action and be more explicit by adding more anchoring text. When I took my CS200 intro to programming class at university some time ago the first couple of weeks of the class was teaching us how to use the text editor. (What? No programming? No, learn to edit files first! I think today they expect students to already know how to edit files, yet from what I can see most students could use a class on it.) And they started us off right at the beginning editing with regular expressions. Literally we had to learn REs before even starting to work on the programming assignments. The department expected us to be proficient editing text! Looking back on it I am glad they did. It has been very useful to me. Bob