How to implement invisible text in Emacs?

Some word processing programs (such as Apple Words) have an interesting feature for supporting vanishing text.

This type of text is used as a placeholder in template files: if I start a new report from a template, some records are filled with disappearing text, which disappears when the text is inserted into the area corresponding to the text or its border. This text is also identified with a special look.

How can I implement fading text in Emacs, if at all possible? This may be enough to support it in buffers with rich text or marking.

+3
source share
1 answer

The following snippet may give you an idea.

(defun remove-evanescent (oldpos newpos)
  "We need that later on to remove evanescent text. We could also remove the superfluous space here."
  (remove-text-properties newpos
              (next-property-change newpos)
              '(display nil point-entered nil)))

;; An elisp-snippet to be tried in the *scratch* buffer:
(insert (propertize " " 'display "Help"
            'point-entered 'remove-evanescent))
+5
source

All Articles