In Emacs, what's the opposite of invisible text?

Viewed 99

You can't see invisible text in the buffer, but if you save the file, it'll be there. I want the oppsoite -- something to display, but if I save the file it won't be written to disk.

In particular I want to display an ellipsis (the "..." symbol) where I have hidden text.

In case it's relevant, here's the code where I'd like to do that. The "fold" function hides text, and the "unfold" function shows it again. The region folded or unfolded is every line just below the current one with more leading space than the current one.

1 Answers

If you set the invisible property to a custom symbol my-fold:

(put-text-property startRegion endRegion 'invisible
                   (if toHide 'my-fold nil))

You can say that my-fold invisibility should use an ellipsis:

;; Cause use of ellipses for invisible text.
(add-to-invisibility-spec '(my-fold . t))

Further reading:

  • C-hig (elisp)Invisible Text
  • C-hig (elisp)Replacing Specs
Related