From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: isearch-allow-move [Was: isearch-allow-prefix] Date: Fri, 07 Jun 2013 09:59:49 +0300 Organization: JURTA Message-ID: <87ehcexw3u.fsf@mail.jurta.org> References: <20130524093858.GA2754@acm.acm> <87hahstd47.fsf@mail.jurta.org> <20130525200103.GA3451@acm.acm> <878v32aj3c.fsf@mail.jurta.org> <20130602210512.GC2765@acm.acm> <87sj0xn484.fsf@mail.jurta.org> <20130604212400.GB2492@acm.acm> <87d2s1otjb.fsf@mail.jurta.org> <20130605210241.GA3730@acm.acm> <8761xr93h5.fsf_-_@mail.jurta.org> <20130606200719.GA3911@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1370589884 15628 80.91.229.3 (7 Jun 2013 07:24:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Jun 2013 07:24:44 +0000 (UTC) Cc: Stefan Monnier , Drew Adams , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 07 09:24:40 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ukr2N-00020a-6C for ged-emacs-devel@m.gmane.org; Fri, 07 Jun 2013 09:24:39 +0200 Original-Received: from localhost ([::1]:51831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukr2K-0005p6-M2 for ged-emacs-devel@m.gmane.org; Fri, 07 Jun 2013 03:24:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukr2F-0005nt-Nj for emacs-devel@gnu.org; Fri, 07 Jun 2013 03:24:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ukr2E-0007x8-Ly for emacs-devel@gnu.org; Fri, 07 Jun 2013 03:24:31 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:56305 helo=ps18281.dreamhostps.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukr2E-0007wv-G0 for emacs-devel@gnu.org; Fri, 07 Jun 2013 03:24:30 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 6A55C258B9E938; Fri, 7 Jun 2013 00:24:27 -0700 (PDT) In-Reply-To: <20130606200719.GA3911@acm.acm> (Alan Mackenzie's message of "Thu, 6 Jun 2013 20:07:19 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 69.163.218.105 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160189 Archived-At: > But what does it mean to C-f with a prefix arg of -1? Does it mean > "remove the last char from the search string"? If not, why not? > Or maybe a negative prefix argument would cause the command to be ignored. > > Or maybe C-b would be allowed here to remove the last char from the > search string. Good idea. This is implemented now by this patch (cumulative to the previously sent one) where `C-b' or `C-u -1 C-f' removes the last char from the search string (`M-b' removes the last word, `C-M-b' removes the last expression, etc. allowing key sequences like `M-s C-b M-b C-M-b'), and eventually stops removing characters at the beginning of the current match when the search string becomes empty. Is this approach simple enough and intuitive? === modified file 'lisp/isearch.el' --- lisp/isearch.el 2013-06-07 04:57:40 +0000 +++ lisp/isearch.el 2013-06-07 06:51:29 +0000 @@ -2367,11 +2370,17 @@ (defvar isearch-allow-move-temporarily n the value of this variable is set to nil.") (put 'right-char 'isearch-move t) +(put 'left-char 'isearch-move t) (put 'forward-char 'isearch-move t) +(put 'backward-char 'isearch-move t) (put 'forward-word 'isearch-move t) +(put 'backward-word 'isearch-move t) (put 'forward-sexp 'isearch-move t) +(put 'backward-sexp 'isearch-move t) (put 'forward-paragraph 'isearch-move t) +(put 'backward-paragraph 'isearch-move t) (put 'move-end-of-line 'isearch-move t) +(put 'move-beginning-of-line 'isearch-move t) ;; Handle universal argument for motion commands when both ;; `isearch-allow-scroll' and `isearch-allow-prefix' are nil. @@ -2546,9 +2549,25 @@ (defun isearch-other-meta-char (&optiona ;; Use the last key in the sequence. (vector (aref key (1- (length key)))))))) (setq prefix-arg arg) - (isearch-yank-internal - (lambda () (command-execute move-command) (point))) - (isearch-update) + (let* ((old-point (or (and (not isearch-forward) isearch-other-end) + (point))) + (new-point (save-excursion + (goto-char old-point) + (command-execute move-command) + (point)))) + (if (< old-point new-point) + ;; Add text to the search string. + (isearch-yank-string + (buffer-substring-no-properties old-point new-point)) + ;; Remove text from the search string. + (setq isearch-string (substring isearch-string 0 + (max (- (length isearch-string) + (- old-point new-point)) 0)) + isearch-message (mapconcat 'isearch-text-char-description + isearch-string "")) + ;; Don't move cursor in reverse search. + (setq isearch-yank-flag t) + (isearch-search-and-update))) (setq isearch-allow-move-temporarily t)) ;; A mouse click on the isearch message starts editing the search string ((and (eq (car-safe main-event) 'down-mouse-1)