From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#39154: 27.0.60; Use character history in zap-up-to-char Date: Thu, 23 Jan 2020 14:51:23 +0100 Message-ID: <87lfpyp9gk.fsf@calancha-pc.dy.bbexcite.jp> References: <87blr31bkn.fsf@calancha-pc.dy.bbexcite.jp> <877e1rexzi.fsf@mail.linkov.net> <87a76jm0u9.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="101018"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39154@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 23 17:49:43 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iuffq-000QEY-Md for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jan 2020 17:49:42 +0100 Original-Received: from localhost ([::1]:60978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuffp-0006sQ-8n for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jan 2020 11:49:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuctw-0000dt-1g for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 08:52:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuctu-0000fe-9Q for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 08:52:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuctu-0000fU-5q for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 08:52:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iuctu-00079R-4F for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 08:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jan 2020 13:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39154 X-GNU-PR-Package: emacs Original-Received: via spool by 39154-submit@debbugs.gnu.org id=B39154.157978749827456 (code B ref 39154); Thu, 23 Jan 2020 13:52:02 +0000 Original-Received: (at 39154) by debbugs.gnu.org; 23 Jan 2020 13:51:38 +0000 Original-Received: from localhost ([127.0.0.1]:51996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iuctW-00078m-9C for submit@debbugs.gnu.org; Thu, 23 Jan 2020 08:51:38 -0500 Original-Received: from mail-wr1-f41.google.com ([209.85.221.41]:34033) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iuctU-00078Y-7V for 39154@debbugs.gnu.org; Thu, 23 Jan 2020 08:51:36 -0500 Original-Received: by mail-wr1-f41.google.com with SMTP id t2so3192673wrr.1 for <39154@debbugs.gnu.org>; Thu, 23 Jan 2020 05:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=WAxlh7uYqgN7OZqktk8fZQu4BsnsW6MIPUoiT5KMTuA=; b=SY5PjRAKKeGjCGpV7+D8V0da8bce/sjMs7+FxMhkD2PXVU042D2mgD6+TvEXBudTVy nt1HnO0kBbWxGKIKmqC7igy2h8asv9yqwERLBp6dnB6I8Us6eKkinxQAPqe7MgHPyNvd zsq+v/fXAztvfkO7v3GkS/HdHjyHNOKMGpWg5JXT2eRu42RwGHhJggZphGimw2yyzsnJ 9iIc9NGiXH+jrK8hPcoRWBO77Mk1q5t4HMPuE4RE5pAp4ivABpEdEsxDwuAUQ/5L4PMy rfyn7yL9AZgef4oS4wvQC8T7ubhvIcZVNd3smgzEZvqAOW1shf/bps22w1MChhZIHWCQ tr+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=WAxlh7uYqgN7OZqktk8fZQu4BsnsW6MIPUoiT5KMTuA=; b=FPayEvP9cUSUta+C1kZBoZT4CBfLwpVKDcghxZs2UC8fdAA7xELrWhGX29lG92h+/F MsTLjuS1j0U3hGMnpLmfsqynuzwtZ25xTa9KuNW0XU0C93UBX+yaoVJ9mJDH9xtNucv9 VwLAjDSnYuHGgM7/hnsMaOIsAidcKhva49mBiQ40fkhczBCR9FNxI/wctjbMY++6OzDt vYI5k9dAHdRgejwppivW/YkQZjuGR9P95Oo6HLxpAreALqR2un42HGgPz0n8b9i7qS+H mNQkbe5mGat7lSYg4VtYD6rf61kerjnrCHAEjjN3cftQhKXCroebiP3kwi75709nF5ph ID+g== X-Gm-Message-State: APjAAAWs/cSwLFKtqThAspkYs/TaUID9xBElhxVeVYV29Db/iSlUNrpM yJMfAsFeHqrYRrFFVeROFvjQsScl X-Google-Smtp-Source: APXvYqzvmcUSXfLtUgy9CtF060hE8Ci+EDiOOPaVqcbz+IGUAvbBBNyOS79Hxxk6wrqoI/6M0aN2+g== X-Received: by 2002:adf:e5ca:: with SMTP id a10mr19048276wrn.347.1579787489619; Thu, 23 Jan 2020 05:51:29 -0800 (PST) Original-Received: from calancha-pc.dy.bbexcite.jp ([195.135.221.19]) by smtp.gmail.com with ESMTPSA id k16sm3421061wru.0.2020.01.23.05.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 05:51:28 -0800 (PST) In-Reply-To: <87a76jm0u9.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 20 Jan 2020 02:24:30 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175161 Archived-At: Juri Linkov writes: > Better to leave alone the name of the existing command since > "up-to-char" and "until-char" are synonyms. > >> - Add similar funtion `iseach-yank-to-char' (i.e. one that inserts CHAR >> in the seach string). > > Yes, this is a good name consistent with zap-to-char. We have discussed two topics in this report, thus I am proposing the following two commits: I) Adjust interactive specificaion for `zap-up-to-char': --8<-----------------------------cut here---------------start------------->8--- commit fe77bb9c2793fd7856c514f41e7a2ce4ccbc4f18 Author: Tino Calancha Date: Thu Jan 23 14:42:29 2020 +0100 Use character history in zap-up-to-char Extend commit 'Add CHARS arg to read-char-from-minibuffer compatible with read-char-choice.' (04ab67470706f1c66bdf08e4078ea3dffd79b41e) to `zap-up-to-char'. * lisp/misc.el (lisp/misc.el): Use same interactive specification as in `zap-to-char' (Bug#39154). * etc/NEWS (Editing Changes in Emacs 27.1): Mention zap-up-to-char as well. diff --git a/etc/NEWS b/etc/NEWS index 792851e5af..2228a4bd25 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -603,10 +603,10 @@ navigation and editing of large files. +++ ** 'zap-to-char' now uses the history of characters you used to zap to. -'zap-to-char' uses the new 'read-char-from-minibuffer' function to allow -navigating through the history of characters that have been input. -This is mostly useful for characters that have complex input methods -where inputting the character again may involve many keystrokes. +'zap-to-char' and 'zap-up-to-char' use the new 'read-char-from-minibuffer' +function to allow navigating through the history of characters that +have been input. This is mostly useful for characters that have complex +input methods where inputting the character again may involve many keystrokes. +++ ** 'save-some-buffers' now has a new action in the prompt: 'C-f' will diff --git a/lisp/misc.el b/lisp/misc.el index 05244a6ea2..af5725555b 100644 --- a/lisp/misc.el +++ b/lisp/misc.el @@ -69,7 +69,9 @@ zap-up-to-char Case is ignored if `case-fold-search' is non-nil in the current buffer. Goes backward if ARG is negative; error if CHAR not found. Ignores CHAR at point." - (interactive "p\ncZap up to char: ") + (interactive (list (prefix-numeric-value current-prefix-arg) + (read-char-from-minibuffer "Zap up to char: " + nil 'read-char-history))) (let ((direction (if (>= arg 0) 1 -1))) (kill-region (point) (progn --8<-----------------------------cut here---------------end--------------->8--- II) Add new command `isearch-yank-to-char'. - It is desirable to add a keybinding for it as well. Tentatively, I have used C-M-p in this patch; please, suggest me the one that fit better. --8<-----------------------------cut here---------------start------------->8--- commit 97ffdf08dc5311989d8ee8fa0a07ce0f6695c021 Author: Tino Calancha Date: Thu Jan 23 14:42:34 2020 +0100 Add command isearch-yank-to-char * lisp/isearch.el (isearch-yank-to-char): New command; bind it to C-M-p at isearch-mode-map (Bug#39154). * etc/NEWS (Search and Replace): Announce it. * doc/emacs/search.texi (Isearch Yank): Update the manual. diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index 16916617a2..0ebae16d99 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi @@ -283,6 +283,14 @@ Isearch Yank useful for keyboard macros, for example in programming languages or markup languages in which that character marks a token boundary. With a prefix numeric argument of @var{n}, the command appends everything +from point up to the @var{n}th occurrence of the specified character. + +@kindex C-M-p @r{(Incremental search)} +@findex isearch-yank-to-char + Likewise, @kbd{C-M-p} (@code{isearch-yank-to-char}) appends to +the search string everything from point to the next occurrence of +a specified character (including that character). With +a prefix numeric argument of @var{n}, the command appends everything from point to the @var{n}th occurrence of the specified character. @kindex C-y @r{(Incremental search)} diff --git a/etc/NEWS b/etc/NEWS index 2228a4bd25..10dd121c50 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1803,7 +1803,9 @@ highlight in one iteration while processing the full buffer. 'C-M-z' invokes new function 'isearch-yank-until-char', which yanks everything from point up to but not including the specified character into the search string. This is especially useful for -keyboard macros. +keyboard macros. Likewise, 'C-M-p' calls the new function +'isearch-yank-to-char', which yanks everything from point to +the specified character (including it) 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 diff --git a/lisp/isearch.el b/lisp/isearch.el index ddf9190dc6..cb52e4ffd4 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -709,6 +709,7 @@ isearch-mode-map (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-\C-p" 'isearch-yank-to-char) (define-key map "\M-s\C-e" 'isearch-yank-line) (define-key map "\M-s\M-<" 'isearch-beginning-of-buffer) @@ -1004,6 +1005,8 @@ isearch-forward 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-to-char] to yank from point to 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. @@ -2593,6 +2596,24 @@ isearch-yank-until-char (sit-for 2))) (point))))) +(defun isearch-yank-to-char (char &optional arg) + "Pull everything to next instance of CHAR from buffer into search string. +Interactively, prompt for CHAR. +If optional ARG is non-nil, pull to next ARGth instance of CHAR. + +See `isearch-yank-until-char' for a similar command that pull everything +until CHAR, i.e. it doesn't include CHAR." + (interactive "cYank to character: \np") + (isearch-yank-internal + (lambda () (let ((inhibit-field-text-motion t)) + (condition-case nil + (progn + (search-forward (char-to-string char) nil nil arg)) + (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." --8<-----------------------------cut here---------------end--------------->8--- Patches on top of emacs-27 commit 'Minor doc string clarification in use-hard-newlines' (7d1e9c943ffa3ded122ef3c8755e05dfb5e9c33f)