]> git.eshelyaron.com Git - emacs.git/commitdiff
Suggest region contents in highlight-regexp when region active
authorEarl <ej32u@protonmail.com>
Mon, 28 Sep 2020 12:16:22 +0000 (14:16 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 28 Sep 2020 12:16:22 +0000 (14:16 +0200)
* lisp/hi-lock.el (hi-lock-face-buffer): Use the region in the
prompt if the region is active in transient-mark-mode (bug#43641).

lisp/hi-lock.el

index c386b7c80129b9339a271df5356af2d1fc60d0f8..1c55a23764d6fd25baf6271b6fad94cb7e4f7569 100644 (file)
@@ -484,7 +484,13 @@ the major mode specifies support for Font Lock."
   (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))