From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Roehler Newsgroups: gmane.emacs.help Subject: Re: region around search hit Date: Wed, 26 Jul 2006 14:16:40 +0200 Organization: 1&1 Internet AG Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: sea.gmane.org 1153917652 18083 80.91.229.2 (26 Jul 2006 12:40:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 Jul 2006 12:40:52 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 26 14:40:50 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G5igm-0006gN-GN for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jul 2006 14:40:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G5igm-0003OM-0C for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jul 2006 08:40:36 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.news.ucla.edu!ucberkeley!news-hog.berkeley.edu!tethys.csu.net!newshub.sdsu.edu!newsfeed.freenet.de!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 50 Original-NNTP-Posting-Host: p54beb941.dip0.t-ipconnect.de Original-X-Trace: online.de 1153915887 7440 84.190.185.65 (26 Jul 2006 12:11:27 GMT) Original-X-Complaints-To: abuse@einsundeins.com Original-NNTP-Posting-Date: Wed, 26 Jul 2006 12:11:27 +0000 (UTC) User-Agent: KNode/0.9.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:140613 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:36238 Archived-At: Drew Adams wrote: > This could be programmed, but I'm wondering if there is already > a quick way to do this: set the region around the last search > occurrence, when isearch is exited. Likewise, for query-replace > (even if exited with C-g). ;; works so far with isearch-forward ;; you have to customize `isearch-set-region' to t before it takes effect ;; with isearch-backward isearch-pos-to-region still doesn't work that way (defcustom isearch-set-region nil "If the region around the last search occurrence, when isearch is exited, should be set" :type 'boolean :group 'isearch) (defun isearch-pos-to-region () "Set the region with beginning- and end-positions of the last isearch-string found" (interactive) (when isearch-set-region (goto-char (- isearch-success (length isearch-string))) (transient-mark-mode t) (push-mark) (goto-char isearch-success))) ;; isearch-mode-end-hook (defun isearch-exit () "Exit search normally. However, if this is the first command after starting incremental search and `search-nonincremental-instead' is non-nil, do a nonincremental search instead via `isearch-edit-string'." (interactive) (if (and search-nonincremental-instead (= 0 (length isearch-string))) (let ((isearch-nonincremental t)) (isearch-edit-string))) (isearch-done) (isearch-clean-overlays) ;; 2006-07-26 a.roehler@web.de changed section start (isearch-pos-to-region) ) ;; 2006-07-26 a.roehler@web.de changed section end