GNU bug report logs - #33852
26.1; unhighlight-regexp unnecessary prompt

Previous Next

Package: emacs;

Reported by: Xiansheng Ca <caxiansheng <at> gmail.com>

Date: Sun, 23 Dec 2018 18:19:02 UTC

Severity: minor

Tags: moreinfo

Found in version 26.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Xiansheng Ca <caxiansheng <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; unhighlight-regexp unnecessary prompt
Date: Sun, 23 Dec 2018 04:49:30 -0600
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 <at> 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




This bug report was last modified 4 years and 289 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.