Is it possible to highlight the characters in a line when the cursor is hovering over that line?

-- johnbendi 2016-06-01 14:43 UTC


----

Do you mean highlight the line under the mouse pointer?

You can do that using library '''<tt>[[highlight.el]]</tt>''' by putting property `mouse-face' on the line, either as a text property or as an overlay.  That is, you use property `mouse-face' instead of property `face'.

And in fact there is a command for this: '''`hlt-mouse-face-each-line''''. It makes each line in the region highlighted when you hover the mouse over that line.

With a prefix arg it prompts you for the highlighting face to use. Use `C-h f hlt-mouse-face-each-line' for more info.

-- DrewAdams 2016-06-01 16:16 UTC


----

With emacs 24.5.1, I found I had to set hlt-use-overlays-flag to nil to get any highlighting.  Based on the discussion that's faster as well, perhaps this should be the default?

-- MarkPurtill 2016-11-04 17:23 UTC


----

With the following code...

    (hlt-highlight-regexp-region (point-min) (point-max) "xxxx" 'hi-pink)

...if I have text like xxxxxxxxxxxxxxxxxxxxxxxxxxx, every fifth x does not get highlighted.

I would expect no gaps in the highlighting.

By way of comparison, if I use...

    (highlight-regexp "xxxx" 'hi-pink)

...there are no gaps in the highlighting.

Is this a bug?

-- nomis 2019-07-08 20:46 UTC


----

(giving my real name this time…)

I think I've tracked down the cause of the above-mentioned gaps in highlighting to an unnecessary use of <code>forward-char</code>.

BTW, I should have said that this is with Emacs 26.1 (although I also tried the version at https://www.emacswiki.org/emacs/highlight.el).

With Emacs 26.1, I've hacked a fix that seems to work. See https://github.com/simon-katz/nomis-emacs-configuration/blob/cc3da74f36a92ce5602c6dc521a2f87f914b0a3f/emacs-installation/emacs-init-files/manually-installed/nomis-highlight-hacks.el#L56-L57

Now, if I bind <code>*nomis/hlt/no-leave-gaps?*</code> to <code>t</code> before calling <code>hlt-highlight-regexp-region</code>, I don't get gaps in the highlighting.

This isn't well-tested, so there's a possibility that it breaks things that I haven't tried. (I'm only using the absolute basics of this library.)

-- [http://blogish.nomistech.com/ SimonKatz] 2019-07-09 10:54 UTC

[new:DrewAdams:2019-07-09 17:19 UTC]
Great bug, and longstanding. Thx. I uploaded what I hope is a fix that doesn't break anything ;-).  The `forward-char' is needed when the search matches an empty string at point.

E.g., without any `forward-char' (e.g. your fix) if you try `C-x X h e' with regexp `.*' near the end of a buffer then it loops forever, because the search is successful by matching the empty string at the end of the first line, and it doesn't advance point.

Please let me know, if you discover a problem with the code now. Thx - DrewAdams


----

Thanks. The new code is working for me (for my limited use of the library).

-- [http://blogish.nomistech.com/ SimonKatz] 2019-07-09 18:28 UTC


----

Would it be possible to add a very simple tutorial or few usage examples? I'm a beginner to emacs so it's quite a lot to take in. Thanks very much.

-- julkhami 2021-06-09 20:17 UTC


----

[new:DrewAdams:2021-06-11 20:42 UTC]
[[jukhami]]: What usage examples are you thinking of / looking for? There are many ways to use the library. I have no idea what uses you have in mind. 

A suggestion is to use `C-h k' for the keys, or `C-h f' for the commands, that are mentioned on the wiki page. Those descriptions should give you some idea what they do, and any prompts they show should also help.

I could add an example or two, but let me know what you're looking for, specifically.

Or if you have a specific question, post it to https://emacs.stackexchange.com/questions and I'll try to answer it there.

-- DrewAdams 2021-06-11 20:44 UTC

