From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: PATCH: isearch-yank-until-char Date: Mon, 26 Aug 2019 17:33:41 -0500 Message-ID: <87ef175zga.fsf@red-bean.com> References: <87tvakfnv4.fsf@red-bean.com> <87lfvvjxjs.fsf@mail.linkov.net> <87sgq1r9rb.fsf@red-bean.com> <87lfvt6m1e.fsf@mail.linkov.net> <877e7256uc.fsf@red-bean.com> <604cbbef-7e25-486a-a97a-9bc1adf23928@default> <871rx87b9h.fsf@red-bean.com> <77205e15-f38a-46dc-9451-4030a318900a@default> <874l23ak8m.fsf@red-bean.com> <87a7bvwqg6.fsf@mail.linkov.net> <645496e5-935d-4f9c-9a53-b38a3a83f9fd@default> <87lfvfvabh.fsf@mail.linkov.net> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="225970"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Drew Adams , Emacs developers To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 27 00:35:32 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i2NaF-000wcR-Eq for ged-emacs-devel@m.gmane.org; Tue, 27 Aug 2019 00:35:31 +0200 Original-Received: from localhost ([::1]:58130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2NaD-0004jb-K0 for ged-emacs-devel@m.gmane.org; Mon, 26 Aug 2019 18:35:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50840) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2NYX-000493-QH for emacs-devel@gnu.org; Mon, 26 Aug 2019 18:33:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2NYW-0004xp-H8 for emacs-devel@gnu.org; Mon, 26 Aug 2019 18:33:45 -0400 Original-Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]:45159) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2NYW-0004xi-9t for emacs-devel@gnu.org; Mon, 26 Aug 2019 18:33:44 -0400 Original-Received: by mail-io1-xd36.google.com with SMTP id t3so41349505ioj.12 for ; Mon, 26 Aug 2019 15:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:reply-to:date:in-reply-to :message-id:user-agent:mime-version; bh=/s3/p8wzhqoDBZVBLACpUM+zmmwLNWcOJLxbK8HpkWc=; b=crHLaFufyV+eidLA2uvDh5xaURjum6KDEHWy4ex7OtQAxkGme7QLzbxA1lKT5Ex3WX nZirbEjIM2K8OUFmqxW+MiSuNGP1bBylTdFqgrrm+3cStoBhFIiNc0k3GW1XGA3JWCqk 5IqQGiRwv+eAJJTLusOmNAHRBDyFHCW0ZYxrkaSPJzFKZ6XFClQ7dMph4gMzIDA51UfN Ygt5zW6+w7lrHUGsokvl0RLEBYNYMGZJt5Zp3Ork+diYFoHkDTlixsjyXJ3i+rnztKZr eeEG7Lve230URt6K4cvgb0sfshjfZ84MuUgZ6lVvEky3cj8eK41FqyWUSOO1wBcOA/qt 1RKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:reply-to :date:in-reply-to:message-id:user-agent:mime-version; bh=/s3/p8wzhqoDBZVBLACpUM+zmmwLNWcOJLxbK8HpkWc=; b=GEwxjgtUtPxA1Yf4T4xGMOH0UzM1GPzEM0Y3JC69NG9H+jXqYoXeNSoem0bc449rxI RYYbv1A42/74tRE01j3dQYFVO/1a5Ch+qJmyw8KxfVWx6xTMgeSxSm33A3utLr3IpMrm JstE3FXhzbJSEQTHITvFPYk3syfXMj+G7ml3vIGtz+Y5S2Y5QO/dyQ8duTP6lxv1Edlg ihUfPkGU0GsOPyKYJMI4lcwGUnPfFymKkv1HXPdyqVJsWdmBDksyr5Y7eMV3vxk0cdn4 6mOncwKcrXFBHDQBhB46HXxmaO2f17Ggo5VqLnCDcIJcxGSpk7Q63sKZ01VLtMozPf3g K28A== X-Gm-Message-State: APjAAAW1+Jfba9398tviSctSu/zmsFfSnWshzm6AkyEjXpnrFj+FgCo4 x8kXK8H0yyYcXNysYhnNnEO88NCY X-Google-Smtp-Source: APXvYqwtSxudfAuWy1ZbmhtAhgkNK6Js7bzZ2k4NIlLXSV3EgXNxAwsbeAXUWQ3MWXHn45g7PECvrw== X-Received: by 2002:a5e:c00e:: with SMTP id u14mr3101343iol.196.1566858823348; Mon, 26 Aug 2019 15:33:43 -0700 (PDT) Original-Received: from kwork (74-92-190-114-Illinois.hfc.comcastbusiness.net. [74.92.190.114]) by smtp.gmail.com with ESMTPSA id p1sm8703183iol.11.2019.08.26.15.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:42 -0700 (PDT) In-Reply-To: <87lfvfvabh.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 27 Aug 2019 01:19:46 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d36 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:239600 Archived-At: --=-=-= Content-Type: text/plain On 27 Aug 2019, Juri Linkov wrote: >`M-.' and `C-M-.' are good keys for pulling text >into the minibuffer, as well as into a search string, >so let's reserve them for the text pulling feature. > >> For `isearch-yank-until-char', I'm not partial >> to any particular key. I'm just partial to not >> using `C-M-c' for that command. > >Then for `isearch-yank-until-char' let's use `C-M-z' >with mnemonics pointing to its similarity with `M-z' >(zap-to-char). I like that. Revised patch attached. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=isearch-yank-until-char-20190826-4.txt [[[ Add `isearch-yank-until-char' * lisp/isearch.el (isearch-yank-until-char): New function. (isearch-mode-map, isearch-menu-bar-yank-map): Add it. (isearch-forward): Document the new binding. * doc/emacs/search.texi (Isearch Yanking): Document the feature. * etc/NEWS: Mention the above. ]]] --- doc/emacs/search.texi +++ doc/emacs/search.texi @@ -262,11 +262,17 @@ Isearch Yank @kindex M-s C-e @r{(Incremental search)} @findex isearch-yank-line - Similarly, @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest + @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest of the current line to the search string. If point is already at the end of a line, it appends the next line. With a prefix argument @var{n}, it appends the next @var{n} lines. +@kindex C-M-z @r{(Incremental search)} +@findex isearch-yank-until-char + Similarly, @kbd{C-M-z} (@code{isearch-yank-until-char}) appends to +the search string everything from point until the next occurence of +a specified character (not including that character). + @kindex C-y @r{(Incremental search)} @kindex M-y @r{(Incremental search)} @kindex mouse-2 @r{in the minibuffer (Incremental search)} --- etc/NEWS +++ etc/NEWS @@ -1202,6 +1202,10 @@ highlight in one iteration while processing the full buffer. +++ *** New isearch bindings. +'C-M-z' invokes new function 'isearch-yank-until-char', which yanks +everything from point to the specified character into the search +string. + 'C-M-w' in isearch changed from 'isearch-del-char' to the new function 'isearch-yank-symbol-or-char'. 'isearch-del-char' is now bound to 'C-M-d'. --- lisp/isearch.el +++ lisp/isearch.el @@ -514,6 +514,9 @@ isearch-menu-bar-yank-map (define-key map [isearch-yank-kill] '(menu-item "Current kill" isearch-yank-kill :help "Append current kill to search string")) + (define-key map [isearch-yank-until-char] + '(menu-item "Until char..." isearch-yank-until-char + :help "Yank from point to specified character into search string")) (define-key map [isearch-yank-line] '(menu-item "Rest of line" isearch-yank-line :help "Yank the rest of the current line on search string")) @@ -705,6 +708,7 @@ isearch-mode-map (define-key map "\M-\C-d" 'isearch-del-char) (define-key map "\M-\C-y" 'isearch-yank-char) (define-key map "\C-y" 'isearch-yank-kill) + (define-key map "\M-\C-z" 'isearch-yank-until-char) (define-key map "\M-s\C-e" 'isearch-yank-line) (define-key map "\M-s\M-<" 'isearch-beginning-of-buffer) @@ -998,6 +1002,8 @@ isearch-forward Type \\[isearch-del-char] to delete character from end of search string. Type \\[isearch-yank-char] to yank char from buffer onto end of search\ string and search for it. +Type \\[isearch-yank-until-char] to yank from point until the next instance\ + of a specified character onto end of search string and search for it. Type \\[isearch-yank-line] to yank rest of line onto end of search string\ and search for it. Type \\[isearch-yank-kill] to yank the last string of killed text. @@ -2562,6 +2568,21 @@ isearch-yank-word (interactive "p") (isearch-yank-internal (lambda () (forward-word arg) (point)))) +(defun isearch-yank-until-char (char) + "Pull everything until next instance of CHAR from buffer into search string. +Interactively, prompt for CHAR." + (interactive "cYank until character: ") + (isearch-yank-internal + (lambda () (let ((inhibit-field-text-motion t)) + (condition-case nil + (progn + (search-forward (char-to-string char)) + (forward-char -1)) + (search-failed + (message "`%c' not found" char) + (sit-for 2))) + (point))))) + (defun isearch-yank-line (&optional arg) "Pull rest of line from buffer into search string. If optional ARG is non-nil, yank the next ARG lines." --=-=-=--