unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43641: Suggest region contents in highlight-regexp when region active
@ 2020-09-27  1:27 ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-09-28 12:18 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-09-27  1:27 UTC (permalink / raw)
  To: 43641

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

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-When-region-active-suggest-region-contents-in-highli.patch --]
[-- Type: text/x-patch; name=0001-When-region-active-suggest-region-contents-in-highli.patch, Size: 1027 bytes --]

From 9b3ce911e15a12f55d36cf56be07a02d29620287 Mon Sep 17 00:00:00 2001
From: Earl <ej32u@protonmail.com>
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


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

* bug#43641: Suggest region contents in highlight-regexp when region active
  2020-09-27  1:27 bug#43641: Suggest region contents in highlight-regexp when region active ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-09-28 12:18 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-28 12:18 UTC (permalink / raw)
  To: ej32u; +Cc: 43641

ej32u@protonmail.com writes:

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

I use neither transient-mark-mode nor hi-lock, so I'm not really that
qualified here, but the patch makes sense to me, so I've committed it to
Emacs 28.

A tiny nit for future patches -- including ChangeLog-style text (created
via `C-x 4 a') would be nice.

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





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

end of thread, other threads:[~2020-09-28 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27  1:27 bug#43641: Suggest region contents in highlight-regexp when region active ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-28 12:18 ` 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).