Subject: 25.0.50; [PATCH] hi-lock interactive functions now default to the active region, if there is one

From: Dima Kogan <[email-masked]>
Date: Sun, 12 Oct 2014 15:35:55 -0700

Hi.

Attached is a small feature patch. Currently when a hi-lock.el function
is called interactively, the default offered by (read-regexp) is the
last value.

With the patch, the behavior is the same if no active region is
available; if an active region IS available, the default is the contents
of the region.

Perhaps something like this should be added to (read-regexp), but that's
a bigger proposal than this small patch.

>From ccf892b48f8bb93c6352f611b4256cb401222668 Mon Sep 17 00:00:00 2001
From: Dima Kogan <[email-masked]>
Date: Sun, 12 Oct 2014 15:32:02 -0700
Subject: [PATCH] hi-lock interactive functions now default to the active
 region, if there is one

---
 lisp/hi-lock.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index 98a26dd..6b06d08 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -419,7 +419,10 @@ highlighting will not update as you type."
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight line" 'regexp-history-last))
+     (read-regexp "Regexp to highlight line"
+                  (if mark-active
+                      (buffer-substring-no-properties (point) (mark))
+                    'regexp-history-last)))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -443,7 +446,10 @@ highlighting will not update as you type."
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight" 'regexp-history-last))
+     (read-regexp "Regexp to highlight"
+                  (if mark-active
+                      (buffer-substring-no-properties (point) (mark))
+                    'regexp-history-last)))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -468,7 +474,10 @@ highlighting will not update as you type."
    (list
     (hi-lock-regexp-okay
      (hi-lock-process-phrase
-      (read-regexp "Phrase to highlight" 'regexp-history-last)))
+      (read-regexp "Phrase to highlight"
+                   (if mark-active
+                       (buffer-substring-no-properties (point) (mark))
+                     'regexp-history-last))))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
-- 
2.0.0