From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tomas Nordin Newsgroups: gmane.emacs.help Subject: Re: killing the result of isearch Date: Sun, 12 Nov 2017 21:02:05 +0100 Message-ID: <87wp2vw9j6.fsf@fliptop> References: <8EEDAF80-5CD1-4BEE-8DB2-262BEDA7C829@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1510516974 32713 195.159.176.226 (12 Nov 2017 20:02:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 12 Nov 2017 20:02:54 +0000 (UTC) To: Jean-Christophe Helary , Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 12 21:02:49 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 1eDySt-00088v-En for geh-help-gnu-emacs@m.gmane.org; Sun, 12 Nov 2017 21:02:47 +0100 Original-Received: from localhost ([::1]:51139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDyT0-0003fI-Nb for geh-help-gnu-emacs@m.gmane.org; Sun, 12 Nov 2017 15:02:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDySX-0003ez-8c for help-gnu-emacs@gnu.org; Sun, 12 Nov 2017 15:02:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDySU-0000bL-58 for help-gnu-emacs@gnu.org; Sun, 12 Nov 2017 15:02:25 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:59154) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDyST-0000aQ-UP for help-gnu-emacs@gnu.org; Sun, 12 Nov 2017 15:02:22 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 896FD20AEE for ; Sun, 12 Nov 2017 21:02:18 +0100 (CET) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 3yZl6b17XNz10JY; Sun, 12 Nov 2017 21:02:15 +0100 (CET) In-Reply-To: <8EEDAF80-5CD1-4BEE-8DB2-262BEDA7C829@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 185.67.36.66 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:114866 Archived-At: Jean-Christophe Helary writes: >> On Nov 8, 2017, at 2:53, Stefan Monnier wrote: >> >> Many Emacs users rely on isearch for navigation, in which case the above could prove annoying. Also, currently isearch pushes a mark at the position where you started the search > > Thank you, that confirms my understanding. I've been using it with that purpose a number of times and it is very practical, but the fact that it does not give access by default to the match makes it more a navigation (find location) function than something to actually use the match. As an exercise I wrote this. Can you try it. I think it behaves the way you expect sort of. (defun tn-frozen-search (arg &optional start-point) "Search forward for a preloaded frozen term. With a prefix argument prompt for a search term (a regular expression). With no prefix argument, use the last search from the search-ring. Activate the match as a region. Then, if `delete-selection-mode' has been toggled on, one can \"just act\" on that region. This function is for interactive use only. There will be an overwrap with no ding." (interactive "P") (when arg (push (read-string "Search: ") search-ring)) (unless start-point (push-mark nil t nil)) (let ((success (re-search-forward (car search-ring) nil t))) (cond (success (push-mark (car (match-data)) t t)) ((and (= (point) (point-min)) (not success)) (if start-point ;; if search fail and start-point is defined, go back to start ;; point (recursive call) (goto-char start-point) ) (ding) (message "No match for %S" (car search-ring))) ((not success) (if (not start-point) (setq start-point (point))) ;; this makes it just over-wrap with no ding (goto-char (point-min)) (message "frozen search ****OVERWRAP****") (tn-frozen-search nil start-point)) (t (message "semantic error in code"))))) ; hit C-x C-e (global-set-key (kbd "") 'tn-frozen-search) With this setup, hitting F9 will search and select the last searched term. Hitting C-u F9 will giva a prompt for a search term. There are room for improvement of course, but as a starting point maybe.