Subject: bug#43641: Suggest region contents in highlight-regexp when region active

From: [email-masked]
Date: Sun, 27 Sep 2020 01:27:25 +0000

Hello.

It is convenient to highlight a region in transient-mark-mode, and then have 
highlight-regexp suggest the contents of that region.

Thank you.

From 9b3ce911e15a12f55d36cf56be07a02d29620287 Mon Sep 17 00:00:00 2001
From: Earl <[email-masked]>
Date: Sat, 26 Sep 2020 21:07:05 -0400
Subject: [PATCH] When region active, suggest region contents in
 highlight-regexp.

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

diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index 0fe651ace3..8f1cbf1db5 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -484,7 +484,13 @@ hi-lock-face-buffer
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight" 'regexp-history-last))
+     (read-regexp "Regexp to highlight"
+                  (if (use-region-p)
+                      (prog1
+                          (buffer-substring (region-beginning)
+                                            (region-end))
+                        (deactivate-mark))
+                    'regexp-history-last)))
     (hi-lock-read-face-name)
     current-prefix-arg))
   (or (facep face) (setq face 'hi-yellow))
-- 
2.25.1