* Is there a way to hightlight region permanently?
@ 2017-07-02 9:27 Marcin Borkowski
2017-07-02 12:24 ` Stephen Berman
2017-07-02 14:52 ` Drew Adams
0 siblings, 2 replies; 3+ messages in thread
From: Marcin Borkowski @ 2017-07-02 9:27 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
I'd like to have something like `highlight-regexp' and
`unhighlight-regexp', but for the current region. I.e., something that
stays highlighted after I move point and/or mark, and whose highlighting
I can easily turn off when no longer needed.
Any hints? Or should I just code that myself?
TIA,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is there a way to hightlight region permanently?
2017-07-02 9:27 Is there a way to hightlight region permanently? Marcin Borkowski
@ 2017-07-02 12:24 ` Stephen Berman
2017-07-02 14:52 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Berman @ 2017-07-02 12:24 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list
On Sun, 02 Jul 2017 11:27:52 +0200 Marcin Borkowski <mbork@mbork.pl> wrote:
> Hi all,
>
> I'd like to have something like `highlight-regexp' and
> `unhighlight-regexp', but for the current region. I.e., something that
> stays highlighted after I move point and/or mark, and whose highlighting
> I can easily turn off when no longer needed.
>
> Any hints? Or should I just code that myself?
>
> TIA,
If you move point or mark, then you change the region, so what do you
want to do with the old region (which would still be highlighted)?
Maybe secondary selection will serve your purposes:
(info "(emacs) Secondary Selection")
Steve Berman
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Is there a way to hightlight region permanently?
2017-07-02 9:27 Is there a way to hightlight region permanently? Marcin Borkowski
2017-07-02 12:24 ` Stephen Berman
@ 2017-07-02 14:52 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2017-07-02 14:52 UTC (permalink / raw)
To: Marcin Borkowski, Help Gnu Emacs mailing list
> I'd like to have something like `highlight-regexp' and
> `unhighlight-regexp', but for the current region. I.e.,
> something that stays highlighted after I move point
> and/or mark, and whose highlighting I can easily turn
> off when no longer needed.
>
> Any hints? Or should I just code that myself?
1. You can easily do what you ask, using library
`highlight.el'.
https://www.emacswiki.org/emacs/HighlightLibrary
https://www.emacswiki.org/emacs/download/highlight.el
You say "permanently" in your Subject line, but it
sounds like you just want to highlight the text in
the region and have that highlighting persist during
the current Emacs session, or until you remove it.
For that, all you need is command `hlt-highlight-region',
bound by default to `C-x X h r'.
[All of the library commands are bound on prefix key
`C-x X', the `h' is for "highlight" (`u' is for
"unhighlight"), and the `r' is for "region". You can
bind commands to keys individually or use a different
prefix key.]
There are lots of other, related commands, including, for
example, `hlt-highlight-regexp-region' (`C-x X h x').
The single command `hlt-highlight' (`C-x X h h' - I bind
it to `C-x C-y' also) gives you the behaviors of multiple
commands all rolled into one, determined by a prefix arg:
* No prefix arg - highlight all text in region/buffer
* Plain prefix arg (`C-u') or zero prefix arg (`C-0'):
UNhighlight all
* Positive prefix arg (`C-1'): highlight regexp matches
* Negative prefix arg (`C--'): UNhighlight regexp matches
All of the highlighting and unhighlighting commands
can use text property `face', `font-lock-face', or
`mouse-face'. All of them can use an overlay property
instead of, or in addition to, a text property. The
default behavior is to use overlay highlighting.
All of the commands let you choose whether the
highlighting is controlled by font-lock or is
independent of font-lock.
You can highlight zones of text defined by their limits.
You can act across multiple buffers: highlighting,
unhighlighting, swapping one face for another, etc.
You can copy and yank text properties from one bit
of text to another.
You can temporarily hide or show text that you have
highlighted.
If you did really want to save your highlighting
permanently, i.e., have it persist between Emacs
sessions, you can do that too. This bit of doc
describes permanent/persistent highlighting:
https://www.emacswiki.org/emacs/HighlightLibrary#PermanentHighlighting
2. As Stephen Berman suggested, a simple way to
highlight text and have that highlighting stay put
while you move point, is to use the secondary
selection.
Vanilla Emacs lets you use the secondary selection
only using the mouse. That's probably one reason
that few Emacs users use it or even know about it.
You really need ways to create it (selecting text)
and yank it using the keyboard.
Library `second-sel.el' can help.
https://emacswiki.org/emacs/SecondarySelection#second-sel.el
https://www.emacswiki.org/emacs/download/second-sel.el
There are lots of things you can do with the
secondary selection, and there are lots of ways to
create or move it.
In particular, you can create it from the active
region, using command `primary-to-secondary'.
But the most versatile command, which I bind to
`C-M-y', is this one: `secondary-yank|select|move|swap'.
By default it yanks the secondary selection at point.
With a prefix arg it interacts with the active region:
Zero: Select secondary as region.
> 0: Move secondary to region.
< 0: Swap region and secondary.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-02 14:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-02 9:27 Is there a way to hightlight region permanently? Marcin Borkowski
2017-07-02 12:24 ` Stephen Berman
2017-07-02 14:52 ` Drew Adams
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).