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

3
  • 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
    Commented Sep 8, 2017 at 19:02
  • Please update your question with that explanation (which is clear). Thx.
    – Drew
    Commented Sep 8, 2017 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
    Commented Sep 8, 2017 at 19:04

1 Answer 1

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.

6
  • Thanks Drew for super quick reply, I would try this one and see.
    – StupidKris
    Commented Sep 8, 2017 at 19:13
  • Works like a charm, Thanks very much.
    – StupidKris
    Commented Sep 8, 2017 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
    Commented Sep 14, 2017 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
    Commented Sep 14, 2017 at 18:18
  • Thanks very much Drew. I would ask a new question in new post, beginner here as well :)
    – StupidKris
    Commented Sep 14, 2017 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.