You say that with library Highlight "there doesn't seem to be a way to highlight arbitrary text, you can only use the mouse, region, or regexs. I have similar issues with the secondary selection."
You don't say what your "similar issues" are with the secondary selection, so I can't speak to that.
But in any case, what you say about library Highlight is not true.
You can highlight any bits of text in any buffer using library Highlight. And you can do so using either overlay properties (typically face
) or text properties (typically face
).
I'm guessing that you're seeing the word "region" in some command names or descriptions and thinking that you need to activate the region to be able to highlight some stretch of text. That's not true.
Here's the point: You need to somehow specify which text you want to highlight.
That means specifying, somehow, its start and end positions in the buffer. You need not do that by having an active region with point and mark at those positions.
For example, command hlt-highlight-property-with-value
highlights text that has a
given (overlay or text) property with certain values. You don't need to know the start and end for each bit of such text; you need only provide the property and its values. In this case, you are specifying the start and end positions indirectly, by providing the property to look for.
As another example, command hlt-highlight-regexp-region
highlights bits of text that match a regexp. It searches for matches, and uses the start and end of each match as the highlighting limits for that bit of text.
Perhaps your confusion results from the fact that some mentions of "region" in the library refer to the scope of the action of a function, and not to a piece of text to highlight. Such functions act on particular bits of text either (1) throughout the entire buffer or (2) throughout the active region. That says nothing about which bits of text to highlight, within either of those scopes. That latter information also needs to be provided to the functions, somehow (see above).
But other functions highlight only a single bit of text. And some of them have region
in their name. Why? Because interactively the easiest way to provide two buffer positions to a command is using the active region.
Perhaps the most basic function for highlighting is hlt-highlight-region
. Yes, it's a command, which means you can bind it to a key and use it interactively. In that case, the start and end positions of the text to be highlighted are the limits of the active region, or the whole buffer if the region is not active.
But, as C-h f hlt-highlight-region
tells you, these are the parameters of that function. The first two specify the limits of the text to highlight.
(hlt-highlight-region &optional START END FACE MSGP MOUSEP BUFFERS)
Optional args START
and END
are the limits of the area to act on.
They default to the region limits. If the region is not active or
it is empty, then use the whole buffer. (But see BUFFERS
, below.)
Optional 3rd arg FACE
is the face to use.
Interactively, this is the last face that was used for highlighting.
(You can use command hlt-choose-default-face
to choose a different face.)
Optional 4th arg MSGP
non-nil
means to display a progress message.
Interactively, MSGP
is t
.
Optional 5th arg MOUSEP
non-nil
means use mouse-face
, not face
.
Interactively, MOUSEP
is provided by the prefix arg.
Optional 6th arg BUFFERS
is the list of buffers to highlight.
If non-nil
and this command is called interactively then explicit
START
and END
values are ignored, and the actual values are
determined automatically for each buffer, based on whether the
region is active there.
So the answer to your question is that you need only provide a START
and END
position to hlt-highlight-region
, to highlight the buffer text from START
to END
. For example, (hlt-highlight-region 100 250 'highlight)
highlights the text from buffer position (character) 100 to position 250 using face highlight
.