Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement evanescent text in Emacs?

Some word processing software (e.g. Apple Words) has the interesting feature of supporting evanescent text.

This kind of text is used as placeholder in template files: if I start a new Report from a template, some entries are filled with evanescent text which disappears when text is inserted within the region corresponding to the text or its boundary. This text is also identified with a special appearance.

How can I implement evanescent text in Emacs, if at all possible? It might be enough to support it in rich-text or markdown buffers.

like image 911
user40989 Avatar asked Feb 10 '26 03:02

user40989


1 Answers

The following snippet might 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))
like image 60
Tobias Avatar answered Feb 15 '26 12:02

Tobias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!