2

I wonder if there is any package which lets me do this:

  • Hightlight entire line where point is currently located
  • If you move point away, it keeps the that line highlighted
  • Multiple lines can be highlighted in similar way
  • Clear all highlights with another command

I think this is very useful and I wonder someone would have done it already.

-- A newby EMACS lover.

Edit: Adding more explanation Let's say I have a file with 10 lines, I want to highlight 3rd, 5th and 7th line. What I would like to do is, move point to those lines one by one and execute some command (let's say highlight-this-line), it should keep the past highlighted lines as highlighted until let's say clear-highlight-command is executed which should clear all highlights

StupidKris
  • 119
  • 6
  • Sorry, if it wasn't clear enough. Answer to your first question: not exactly. Let me elaborate. Let's say I have a file with 10 lines, I want to highlight 3rd, 5th and 7th line. What I would like to do is, move point to those lines one by one and execute some command (let's say highlight-this-line), it should keep the past highlighted lines as highlighted until let's say clear-highlight-command is executed which should clear all highlights. – StupidKris Sep 08 '17 at 19:02
  • Please update your question with that explanation (which is clear). Thx. – Drew Sep 08 '17 at 19:03
  • Your second question: Yes, I know C-SPC would help but not the way I would like to, that would simply highlight entire text between my last mark and current point location. – StupidKris Sep 08 '17 at 19:04

1 Answers1

2

Use library Highlight (highlight.el).

(defun highlight-this-line ()
  "Highlight the current line."
  (interactive)
  (hlt-highlight-region (line-beginning-position) (line-end-position)))

You can also pass the FACE to use as an arg to hlt-highlight-region.

Drew
  • 77,472
  • 10
  • 114
  • 243
  • Thanks Drew for super quick reply, I would try this one and see. – StupidKris Sep 08 '17 at 19:13
  • Works like a charm, Thanks very much. – StupidKris Sep 08 '17 at 20:50
  • Following up on this, I am also looking for the follwoing:
    1. changing the background color of highlight
    2. having a defun which would clear all highlights in buffer

    Would you suggest something? Thanks

    – StupidKris Sep 14 '17 at 16:54
  • You should ask separate questions for those things. SE is a Q & A site, that intentionally looks for specific questions with specific answers. However: see the Commentary in highlight.el, where it says (1) you can use any face to highlight or unhighlight, (2) you can use command hlt-choose-default-face to choose a face for highlighting, (3) you can alternatively choose a color name instead of a face, and (4) you can also choose a face using command hlt-next-face. See also option hlt-auto-face-backgrounds. Read the Commentary. – Drew Sep 14 '17 at 18:18
  • Thanks very much Drew. I would ask a new question in new post, beginner here as well :) – StupidKris Sep 14 '17 at 23:00
  • The author of that package is YOU! Thank you! – shynur Jun 14 '23 at 01:55