6

I would like to temporarily not be able to see what I am writing (counter-intuitive, I know, but sometimes it's helpful to not be able to immediately criticize what you are writing in order to actually get some writing done).

One solution would be to turn off my display, but that is rather complicated in some situations (most laptops nowadays --including mine-- don't dim to 0% and other solutions are OS dependent). As I use emacs for pretty much any type of writing, I would prefer an emacs solution. As I am lisp-illiterate (still, sigh), I could use some help.

I presume that making text invisible can be done by setting the facecolor to the background color; however, I don't know how to do that outside the Edit>Text properties>Display Faces menu. Furthermore, I would also like to be able to toggle the visibility of the text and I have no idea how to restore the previous color.

Any pointers are appreciated.

2
  • You may be interested in (elisp) Invisible Text.
    – Basil
    Commented Aug 9, 2018 at 14:38
  • @Basil Thank you for your comment. I thought about that approach but it has the significant drawback that cursor motion ignores text that is "invisible" in the emacs-sense. I would like to retain the ability to kill the last couple of words easily without switching the visibility status of the text. Commented Aug 9, 2018 at 15:02

1 Answer 1

5

This seems to work for me. You type M-x disappear to hide the regular text, and M-x reappear to show it again. It does not hide text that uses other faces. Also, if you select a region with your mouse, you will be able to see the text in the highlights. Maybe that is a feature.

(setq default-background (face-attribute 'default :background)
      default-foreground (face-attribute 'default :foreground))

(defun disappear ()
  (interactive)
  (set-face-attribute 'default nil
              :foreground default-background))

(defun reappear ()
  (interactive)
  (set-face-attribute 'default nil
              :foreground default-foreground))
1
  • Thanks, John, it works like a charm on a clean emacs instance (I have some clash in my configuration but I will figure that out). You may want to remove the org-mode code delimiters from your answer (force of habit, eh?). Commented Aug 9, 2018 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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