Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9176009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:00:44+00:00 2026-06-17T17:00:44+00:00

I need to highlight facility for emacs in order to mark some lines in

  • 0

I need to highlight facility for emacs in order to mark some lines in file while working with it.
It should be smth like M-s h l but should work based on line number, not on a regexp. I want to highlight a current line, but the hl-line-mode is not suitable, as I need to highlight many lines, every time I press a specific key on each of them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:00:45+00:00Added an answer on June 17, 2026 at 5:00 pm

    I just quickly wrote the following:

    (defun find-overlays-specifying (prop pos)
      (let ((overlays (overlays-at pos))
            found)
        (while overlays
          (let ((overlay (car overlays)))
            (if (overlay-get overlay prop)
                (setq found (cons overlay found))))
          (setq overlays (cdr overlays)))
        found))
    
    (defun highlight-or-dehighlight-line ()
      (interactive)
      (if (find-overlays-specifying
           'line-highlight-overlay-marker
           (line-beginning-position))
          (remove-overlays (line-beginning-position) (+ 1 (line-end-position)))
        (let ((overlay-highlight (make-overlay
                                  (line-beginning-position)
                                  (+ 1 (line-end-position)))))
            (overlay-put overlay-highlight 'face '(:background "lightgreen"))
            (overlay-put overlay-highlight 'line-highlight-overlay-marker t))))
    
    
    (global-set-key [f8] 'highlight-or-dehighlight-line)
    

    (Here find-overlays-specifying came from the manual page)

    It will highlight current line, and when used again it will remove it.

    Maybe the following could be useful as well: removing all your highlight from the buffer (could be dangerous, you might not want it if you highlight important things)

    (defun remove-all-highlight ()
      (interactive)
      (remove-overlays (point-min) (point-max))
      )
    
    (global-set-key [f9] 'remove-all-highlight)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to highlight some random text to my PDF file. My friend advised
I'm programming an application in Struts and I need to highlight some reminders in
I have a regular texbox control. I need to highlight some words with a
So like a graphics.FillEllipse, but with a hole in the middle. I need to
I need to highlight a list of words in vim, preferably the words should
I'm looking to do something like this but with CSS or JavaScript. I need
I need to highlight or create markers on some annotations using meta information, which
I try to compact some chord files and then need to highlight some stuff
I am using CheckedListBox , but I need to highlight individual items with different
I have some numbers, and depending on the number's value I need to highlight

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.