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

* bug#33852: 26.1; unhighlight-regexp unnecessary prompt
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-01-05  8:56 UTC (permalink / raw)
  To: Xiansheng Ca; +Cc: 33852

> From: Xiansheng Ca <caxiansheng@gmail.com>
> Date: Sun, 23 Dec 2018 04:49:30 -0600
> 
> 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.
> [...]
> +       (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)))))))

What happens if the command is invoked with point on a portion of text
that is highlighted by a hi-lock regexp?  Wouldn't the command then
silently unhighlight only that regexp, and won't allow the user to
specify any other regexp?

IOW, if the list of completions has only one element (btw, this fact
can be more elegantly established by calling 'length'), it does not
necessarily mean that there's only one hi-lock regexp defined in the
buffer.  Should we consider that as well?

Thanks.





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

* bug#33852: 26.1; unhighlight-regexp unnecessary prompt
  2019-01-05  8:56 ` Eli Zaretskii
@ 2020-08-13 12:14   ` Stefan Kangas
  2020-10-01  1:57     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2020-08-13 12:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 33852, Xiansheng Ca

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Xiansheng Ca <caxiansheng@gmail.com>
>> Date: Sun, 23 Dec 2018 04:49:30 -0600
>>
>> 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.
>> [...]
>> +       (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)))))))
>
> What happens if the command is invoked with point on a portion of text
> that is highlighted by a hi-lock regexp?  Wouldn't the command then
> silently unhighlight only that regexp, and won't allow the user to
> specify any other regexp?
>
> IOW, if the list of completions has only one element (btw, this fact
> can be more elegantly established by calling 'length'), it does not
> necessarily mean that there's only one hi-lock regexp defined in the
> buffer.  Should we consider that as well?

That was 1.5 years ago.  Any updates here?  Xiansheng Ca, did you have a
chance to look at Eli's questions above?

Best regards,
Stefan Kangas





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

* bug#33852: 26.1; unhighlight-regexp unnecessary prompt
  2020-08-13 12:14   ` Stefan Kangas
@ 2020-10-01  1:57     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-01  1:57 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 33852, Xiansheng Ca

Stefan Kangas <stefan@marxist.se> writes:

> That was 1.5 years ago.  Any updates here?  Xiansheng Ca, did you have a
> chance to look at Eli's questions above?

There was no followup here, so it seems unlikely that there'll be
further progress made in this bug report, and I'm closing it.  If
progress can be made, please respond to the debbugs address and we'll
reopen the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[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).