[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33852: 26.1; unhighlight-regexp unnecessary prompt
From: |
Xiansheng Ca |
Subject: |
bug#33852: 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@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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#33852: 26.1; unhighlight-regexp unnecessary prompt,
Xiansheng Ca <=