From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Let's make C-M-w in isearch yank symbol, not delete character Date: Fri, 02 Mar 2018 00:32:55 +0200 Organization: LINKOV.NET Message-ID: <87tvtzjvh4.fsf@mail.linkov.net> References: <87po4slrg4.fsf@mail.linkov.net> <831sh82zyf.fsf@gnu.org> <87h8q2w29i.fsf@mail.linkov.net> <83tvu1zsru.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1519944589 18443 195.159.176.226 (1 Mar 2018 22:49:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Mar 2018 22:49:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: dancol@dancol.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 01 23:49:44 2018 Return-path: Envelope-to: ged-emacs-devel@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 1erX1E-0004IB-B9 for ged-emacs-devel@m.gmane.org; Thu, 01 Mar 2018 23:49:44 +0100 Original-Received: from localhost ([::1]:59614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erX3G-0007Jm-Tr for ged-emacs-devel@m.gmane.org; Thu, 01 Mar 2018 17:51:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erX35-0007IC-DO for emacs-devel@gnu.org; Thu, 01 Mar 2018 17:51:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erX34-00027J-1D for emacs-devel@gnu.org; Thu, 01 Mar 2018 17:51:39 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:40105 helo=homiemail-a18.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erX2y-0001yo-Bo; Thu, 01 Mar 2018 17:51:32 -0500 Original-Received: from homiemail-a18.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a18.g.dreamhost.com (Postfix) with ESMTP id 45E30258067; Thu, 1 Mar 2018 14:51:27 -0800 (PST) Original-Received: from localhost.linkov.net (m91-129-98-215.cust.tele2.ee [91.129.98.215]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a18.g.dreamhost.com (Postfix) with ESMTPSA id E8144258066; Thu, 1 Mar 2018 14:51:25 -0800 (PST) In-Reply-To: <83tvu1zsru.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 28 Feb 2018 05:40:05 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 69.163.253.7 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223201 Archived-At: --=-=-= Content-Type: text/plain >> I updated the documentation in the docstring of search-exit-option below. > > This should be in NEWS as well. What about the manual? Here is a new patch with the NEWS entry. Regarding the documentation, I'm pretty sure this is not the final implementation as there will be more changes in that feature before it's ready to be documented in (info "(emacs) Not Exiting Isearch") or in (info "(emacs) Isearch Yank"). --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=search-exit-option.patch diff --git a/etc/NEWS b/etc/NEWS index 596adf8..0d43913 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -180,6 +180,14 @@ created by 'edit-last-kbd-macro', and to save the macro by 'C-c C-c'. --- *** New filter ibuffer-filter-by-process; bound to '/E'. +** Search and Replace + +*** 'search-exit-option' provides new options 'move' and 'shift-move' +to extend the search string by yanking text that ends at the new +position after moving point in the current buffer. `shift-move' +extends the search string by motion commands while holding down +the shift key. + ** Edebug +++ diff --git a/lisp/isearch.el b/lisp/isearch.el index a41adf0..524137a 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -67,8 +67,23 @@ isearch (defcustom search-exit-option t - "Non-nil means random control characters terminate incremental search." - :type 'boolean) + "Defines what control characters do in incremental search. +If t, random control and meta characters terminate the search +and are then executed normally. +If `edit', edit the search string instead of exiting. +If `move', extend the search string by motion commands +that have the `isearch-move' property on their symbols. +If `shift-move', extend the search string by motion commands +while holding down the shift key. +Both `move' and `shift-move' extend the search string by yanking text +that ends at the new position after moving point in the current buffer. +If nil, run the command without exiting Isearch." + :type '(choice (const :tag "Terminate incremental search" t) + (const :tag "Edit the search string" edit) + (const :tag "Extend the search string by motion commands" move) + (const :tag "Extend the search string by shifted motion keys" shift-move) + (const :tag "Don't terminate incremental search" nil)) + :version "27.1") (defcustom search-slow-window-lines 1 "Number of lines in slow search display windows. @@ -2391,6 +2423,7 @@ isearch-back-into-window (goto-char isearch-point)) (defvar isearch-pre-scroll-point nil) +(defvar isearch-pre-move-point nil) (defun isearch-pre-command-hook () "Decide whether to exit Isearch mode before executing the command. @@ -2398,8 +2431,9 @@ isearch-pre-command-hook is bound in `isearch-mode-map', or if the invoked command is a prefix argument command (when `isearch-allow-prefix' is non-nil), or it is a scrolling command (when `isearch-allow-scroll' is non-nil). -Otherwise, exit Isearch (when `search-exit-option' is non-nil) -before the command is executed globally with terminated Isearch." +Otherwise, exit Isearch (when `search-exit-option' is t) +before the command is executed globally with terminated Isearch. +See more for options in `search-exit-option'." (let* ((key (this-single-command-keys)) (main-event (aref key 0))) (cond @@ -2427,6 +2461,14 @@ isearch-pre-command-hook ;; Swallow the up-event. (read-event) (setq this-command 'isearch-edit-string)) + ;; Don't terminate the search for motion commands. + ((or (and (eq search-exit-option 'move) + (symbolp this-command) + (eq (get this-command 'isearch-move) t)) + (and (eq search-exit-option 'shift-move) + this-command-keys-shift-translated)) + (setq this-command-keys-shift-translated nil) + (setq isearch-pre-move-point (point))) ;; Other characters terminate the search and are then executed normally. (search-exit-option (isearch-done) @@ -2436,13 +2478,28 @@ isearch-pre-command-hook (isearch-process-search-string key key))))) (defun isearch-post-command-hook () - (when isearch-pre-scroll-point + (cond + (isearch-pre-scroll-point (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point))) (if ab-bel (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point) (goto-char isearch-pre-scroll-point))) (setq isearch-pre-scroll-point nil) - (isearch-update))) + (isearch-update)) + ((memq search-exit-option '(move shift-move)) + (when (and isearch-pre-move-point + (not (eq isearch-pre-move-point (point)))) + (let ((string (buffer-substring-no-properties + (or isearch-other-end isearch-opoint) (point)))) + (if isearch-regexp (setq string (regexp-quote string))) + (setq isearch-string string) + (setq isearch-message (mapconcat 'isearch-text-char-description + string "")) + (setq isearch-yank-flag t) + (setq isearch-forward (<= (or isearch-other-end isearch-opoint) (point))) + (goto-char isearch-pre-move-point) + (isearch-search-and-update))) + (setq isearch-pre-move-point nil)))) (defun isearch-quote-char (&optional count) "Quote special characters for incremental search. --=-=-=--