bkaestner / redacted.el

GNU General Public License v3.0
106 stars 6 forks source link

+TITLE: ▆▆▆▆▆▆▆▆-mode

=redacted-mode= is an Emacs [[info:emacs#Minor Modes][minor mode]] to hide your current text.

+begin_src emacs-lisp

;; Set up package.el to work with MELPA (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize) (package-refresh-contents)

;; Download redacted (unless (package-installed-p 'redacted) (package-install 'redacted))

+end_src

To automatically run commands when =redacted-mode= is enabled use the provided =redacted-mode-hook=. Here is an example that automatically makes the buffer read-only when =redacted-mode= is enabled:

+begin_src emacs-lisp

;; Enable `read-only-mode' to ensure that we don't change what we can't read. (add-hook 'redacted-mode-hook (lambda () (read-only-mode (if redacted-mode 1 -1))))

+end_src

I thought that Emacs /must/ have some functionality to hide certain information on the displayed text. I remembered =toggle-rot13-mode=, but anyone interested in the text could decrypt it rather quickly. So instead, I had a look into its implementation and put my Emacs Lisp hat on to find my own solution.