My buffer has one line as,

i am sitting on an overlay

Now when i do, M-x some-function-to-hide, i like to hide the text from display, and show three dots as,


I am looking forward to have a "hello world" program to understand overlays.

  • 1
    How about?: (overlay-put (make-overlay (point-at-bol) (point-at-eol)) 'display "...")
    – lawlist
    Feb 27, 2015 at 17:32
  • please, can you make this as answer... an extra info, i brought "..." back to original form using (remove-overlays)
    – Madhavan
    Feb 27, 2015 at 17:34
  • 1
    How about?: (remove-overlays (point-min) (point-max) 'display "...") I am at work today and won't have a chance to do an answer until later. I'm not picky -- anyone can write-up an answer, even yourself if you are so inclined.
    – lawlist
    Feb 27, 2015 at 17:38
  • 3
    Please do some basic research before posting. A google search for "emacs overlay" yields the manual page for "Overlays".
    – Dan
    Feb 27, 2015 at 17:43

1 Answer 1


Reproducing lawlist's comments here, To make an overlay and minify the code block as "...", you can do,

(overlay-put (make-overlay (point-at-bol) (point-at-eol)) 'display "...")

Now, to expand the contents and bring the buffer to its original form,

(remove-overlays (point-min) (point-max) 'display "...")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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