unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33852: 26.1; unhighlight-regexp unnecessary prompt
@ 2018-12-23 10:49 Xiansheng Ca
  2019-01-05  8:56 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Xiansheng Ca @ 2018-12-23 10:49 UTC (permalink / raw)
  To: 33852

Hello,

In hi-lock-mode, after highlighting a single regular expression such
as by M-s h r regexp <RET> <RET>, then unhighlighting with M-s h u,
I'm prompted "Regexp to unhighlight (default regexp):", but any choice
other than the default is rejected with the message "[No Match]". I
would prefer not to be prompted if there is only a single acceptable
choice.

I believe the patch below implements this proposed behavior. Thank you
for taking the time to consider this.

From c7918a6a09e91fc033a7288429ed4c466fba5e7c Mon Sep 17 00:00:00 2001
From: Ca Xiansheng <caxiansheng@gmail.com>
Date: Sun, 23 Dec 2018 03:30:50 -0600
Subject: [PATCH] * lisp/hi-lock.el (unhighlight-regexp): Do not prompt if one
 choice.

---
 lisp/hi-lock.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index 6eadd59..9377d84 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -602,13 +602,13 @@ then remove all hi-lock highlighting."
      ;; Infer the regexp to un-highlight based on cursor position.
      (let* ((defaults (or (hi-lock--regexps-at-point)
                           (mapcar #'car hi-lock-interactive-patterns))))
-       (list
-        (completing-read (if (null defaults)
-                             "Regexp to unhighlight: "
-                           (format "Regexp to unhighlight (default %s): "
-                                   (car defaults)))
-                         hi-lock-interactive-patterns
-             nil t nil nil defaults))))))
+       (list (if (and (consp defaults) (null (cdr defaults))) (car defaults)
+               (completing-read (if (null defaults)
+                                    "Regexp to unhighlight: "
+                                  (format "Regexp to unhighlight
(default %s): "
+                                          (car defaults)))
+                                hi-lock-interactive-patterns
+                        nil t nil nil defaults)))))))
   (dolist (keyword (if (eq regexp t) hi-lock-interactive-patterns
                      (list (assoc regexp hi-lock-interactive-patterns))))
     (when keyword
-- 
2.20.1





^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-01  1:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-23 10:49 bug#33852: 26.1; unhighlight-regexp unnecessary prompt Xiansheng Ca
2019-01-05  8:56 ` Eli Zaretskii
2020-08-13 12:14   ` Stefan Kangas
2020-10-01  1:57     ` Lars Ingebrigtsen

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).