unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18697: 25.0.50; [PATCH] hi-lock interactive functions now default to the active region, if there is one
@ 2014-10-12 22:35 Dima Kogan
  2014-10-12 23:01 ` Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Dima Kogan @ 2014-10-12 22:35 UTC (permalink / raw)
  To: 18697

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-hi-lock-interactive-functions-now-default-to-the-act.patch --]
[-- Type: text/x-diff, Size: 1974 bytes --]

From ccf892b48f8bb93c6352f611b4256cb401222668 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
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


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

end of thread, other threads:[~2019-07-02 12:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-12 22:35 bug#18697: 25.0.50; [PATCH] hi-lock interactive functions now default to the active region, if there is one Dima Kogan
2014-10-12 23:01 ` Drew Adams
2014-10-14 19:32   ` Juri Linkov
2014-10-14 19:48     ` Drew Adams
2014-10-14 20:04       ` Juri Linkov
2014-10-14 20:25         ` Drew Adams
2014-10-14 21:45           ` Drew Adams
2014-10-13 11:12 ` Ivan Shmakov
2014-10-14 18:51   ` Stefan Monnier
2019-06-25 21:29 ` Lars Ingebrigtsen
2019-06-28 19:09   ` Juri Linkov
2019-06-29 10:14     ` Lars Ingebrigtsen
2019-06-30 20:58       ` Juri Linkov
2019-07-02 12:41         ` 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).