From: Jim Porter <jporterbugs@gmail.com>
To: 70882@debbugs.gnu.org
Subject: bug#70882: 30.0.50; [PATCH] Print the real direction in the prompt for '(previous|next)-matching-history-element'
Date: Sat, 11 May 2024 11:53:18 -0700 [thread overview]
Message-ID: <f1a8463a-0ea6-ccec-b3b5-0895991a6e8d@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 514 bytes --]
To see the problem, start from "emacs -Q":
M-x
M-r ;; Emacs prompts "Previous element matching regexp:"
C-g
M-- M-r ;; Emacs prompts "Previous element matching regexp:" (?!)
In the last line, the prefix argument is negative, so the search will
actually be for the *next* matching element. The attached patch fixes
this so that the prompt message accounts for the prefix arg.
While I was here, I also made 'next-matching-history-element' use
'format-prompt' like its 'previous-...' sibling.
[-- Attachment #2: 0001-Tell-direction-in-prompts-for-previous-next-matching.patch --]
[-- Type: text/plain, Size: 3753 bytes --]
From 514ccf9288bf29f74e1b2cdfde52a3bf19ae2833 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 11 May 2024 11:41:11 -0700
Subject: [PATCH] Tell direction in prompts for
'(previous|next)-matching-history-element'
Previously, this always said "Previous" for
'previous-matching-history-element' (likewise "Next"). Now, the prompt
accounts for a negative prefix argument changing the search direction.
* lisp/simple.el (previous-matching-history-element)
(next-matching-history-element): Consult numeric prefix argument to
determine the prompt string.
---
lisp/simple.el | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index deab52c4201..d10e414586f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2876,11 +2876,13 @@ previous-matching-history-element
makes the search case-sensitive.
See also `minibuffer-history-case-insensitive-variables'."
(interactive
- (let* ((enable-recursive-minibuffers t)
+ (let* ((n (prefix-numeric-value current-prefix-arg))
+ (enable-recursive-minibuffers t)
(regexp (read-from-minibuffer
- (format-prompt "Previous element matching regexp"
+ (format-prompt "%s element matching regexp"
(and minibuffer-history-search-history
- (car minibuffer-history-search-history)))
+ (car minibuffer-history-search-history))
+ (if (>= n 0) "Previous" "Next"))
nil minibuffer-local-map nil
'minibuffer-history-search-history
(car minibuffer-history-search-history))))
@@ -2888,9 +2890,9 @@ previous-matching-history-element
(list (if (string= regexp "")
(if minibuffer-history-search-history
(car minibuffer-history-search-history)
- (user-error "No previous history search regexp"))
+ (user-error "No history search regexp"))
regexp)
- (prefix-numeric-value current-prefix-arg))))
+ n)))
(unless (zerop n)
(if (and (zerop minibuffer-history-position)
(null minibuffer-text-before-history))
@@ -2948,20 +2950,23 @@ next-matching-history-element
`case-fold-search' is non-nil, but an uppercase letter in REGEXP
makes the search case-sensitive."
(interactive
- (let* ((enable-recursive-minibuffers t)
- (regexp (read-from-minibuffer "Next element matching (regexp): "
- nil
- minibuffer-local-map
- nil
- 'minibuffer-history-search-history
- (car minibuffer-history-search-history))))
+ (let* ((n (prefix-numeric-value current-prefix-arg))
+ (enable-recursive-minibuffers t)
+ (regexp (read-from-minibuffer
+ (format-prompt "%s element matching regexp"
+ (and minibuffer-history-search-history
+ (car minibuffer-history-search-history))
+ (if (>= n 0) "Next" "Previous"))
+ nil minibuffer-local-map nil
+ 'minibuffer-history-search-history
+ (car minibuffer-history-search-history))))
;; Use the last regexp specified, by default, if input is empty.
(list (if (string= regexp "")
(if minibuffer-history-search-history
(car minibuffer-history-search-history)
- (user-error "No previous history search regexp"))
+ (user-error "No history search regexp"))
regexp)
- (prefix-numeric-value current-prefix-arg))))
+ n)))
(previous-matching-history-element regexp (- n)))
(defvar minibuffer-temporary-goal-position nil)
--
2.25.1
next reply other threads:[~2024-05-11 18:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 18:53 Jim Porter [this message]
2024-05-18 9:18 ` bug#70882: 30.0.50; [PATCH] Print the real direction in the prompt for '(previous|next)-matching-history-element' Eli Zaretskii
2024-05-20 1:35 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f1a8463a-0ea6-ccec-b3b5-0895991a6e8d@gmail.com \
--to=jporterbugs@gmail.com \
--cc=70882@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).