From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: option to let isearch select the search target (in transient mark mode) Date: Tue, 10 Jul 2007 12:58:48 -0700 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1184097612 25873 80.91.229.12 (10 Jul 2007 20:00:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 10 Jul 2007 20:00:12 +0000 (UTC) To: "Emacs-Devel" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 10 22:00:10 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I8LsX-0007yJ-SF for ged-emacs-devel@m.gmane.org; Tue, 10 Jul 2007 22:00:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I8LsW-00062E-Si for ged-emacs-devel@m.gmane.org; Tue, 10 Jul 2007 16:00:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I8LsS-00061u-WB for emacs-devel@gnu.org; Tue, 10 Jul 2007 16:00:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I8LsR-00061Y-Lf for emacs-devel@gnu.org; Tue, 10 Jul 2007 16:00:04 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I8LsR-00061U-Du for emacs-devel@gnu.org; Tue, 10 Jul 2007 16:00:03 -0400 Original-Received: from agminet01.oracle.com ([141.146.126.228]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1I8LsQ-0004qn-QR for emacs-devel@gnu.org; Tue, 10 Jul 2007 16:00:03 -0400 Original-Received: from rgmgw3.us.oracle.com (rgmgw3.us.oracle.com [138.1.186.112]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l6AJxpPw000522 for ; Tue, 10 Jul 2007 14:59:51 -0500 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by rgmgw3.us.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l6AGhfs5011421 for ; Tue, 10 Jul 2007 13:59:50 -0600 Original-Received: from dhcp-amer-csvpn-gw2-141-144-73-85.vpn.oracle.com by acsmt350.oracle.com with ESMTP id 3027239311184097532; Tue, 10 Jul 2007 12:58:52 -0700 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:74579 Archived-At: How about adding this to Isearch: Depending on the value of an option, `isearch-set-region-flag', Isearch leaves the region active around the search target when you stop searching with `RET'. This is only for Transient Mark mode; if that mode is not on, then this does nothing. This feature makes it easy to delete the found text, copy it, or type to replace it in Delete Selection mode. You can toggle the option at any time during searching, with `C-SPC'. I use `isearch-mode-end-hook' to implement this, but it could no doubt be integrated with the Isearch code more directly. Alternatively, `transient-mark-mode' could perhaps add this to or remove it from `isearch-mode-end-hook'. In that case, the test for `transient-mark-mode' would be removed. (defcustom isearch-set-region-flag nil "Non-nil means set region around search target. This is used only for Transient Mark mode. You can toggle this with `isearch-toggle-set-region', bound to `C-SPC' during isearch." :type 'boolean :group 'isearch) (add-hook 'isearch-mode-end-hook 'isearch-set-region) (defun isearch-set-region () "Set the region around the search target, if `isearch-set-region-flag'. This is used only for Transient Mark mode." (when (and isearch-set-region-flag transient-mark-mode) (push-mark isearch-other-end t 'activate))) (defun isearch-toggle-set-region () "Toggle `isearch-set-region-flag'." (interactive) (setq isearch-set-region-flag (not isearch-set-region-flag)) (if isearch-set-region-flag (message "Setting region around search target is now ON") (message "Setting region around search target is now OFF"))) (define-key isearch-mode-map [(control ? )] 'isearch-toggle-set-region) And here is a standalone command, for users who want to do this only upon demand and leave `isearch-set-region-flag' = nil: (defun set-region-around-search-target () "Set the region around the last search or query-replace target." (interactive) (case last-command ((isearch-forward isearch-backward isearch-forward-regexp isearch-backward-regexp) (push-mark isearch-other-end t 'activate)) (t (push-mark (match-beginning 0) t 'activate))) (setq deactivate-mark nil))