mirror of
https://github.com/erickgnavar/cloak-mode.git
synced 2026-04-19 21:33:00 +00:00
A minor mode to hide sensitive values in buffers per major mode
- Emacs Lisp 100%
|
|
||
|---|---|---|
| cloak-mode.el | ||
| demo.gif | ||
| LICENSE | ||
| README.md | ||
Cloak-mode
Minor mode to cloak sensitive data
Motivation
I used to use hidepw package but it only supports a plain list of regexs and also use font locking which have some conflicts with other packages, cloak-mode allows to setup a regex by major mode, which fits betters for my use case.
Demo
Installation
Cloning the repo
Clone this repo somewhere, and add this to your config:
(add-to-list 'load-path "path where the repo was cloned")
;; for example we load it for envrc files
(require 'cloak-mode)
(setq cloak-mode-patterns '((envrc-file-mode . "[a-zA-Z0-9_]+[ \t]*=[ \t]*\\(.*+\\)$")))
(global-cloak-mode)
;; or for a buffer by name
(require 'cloak-mode)
(setq cloak-mode-patterns '(("*scratch*" . "[a-zA-Z0-9_]+[ \t]*=[ \t]*\\(.*+\\)$")))
(global-cloak-mode)
Using use-package
(use-package cloak-mode
:ensure t
:config
(global-cloak-mode))
Using straight.el
(use-package cloak-mode
:straight (cloak-mode
:type git
:host github
:repo "erickgnavar/cloak-mode")
:config
(global-cloak-mode))
Examples
Single pattern per mode
In case we need just one pattern we can define directly as a string
(setq cloak-mode-patterns '((envrc-file-mode . "[a-zA-Z0-9_]+[ \t]*=[ \t]*\\(.*+\\)$")))
Many patterns per mode
In case we need many patterns we can define a list of strings
(setq cloak-mode-patterns '((envrc-file-mode . ("first-pattern" "second pattern"))))
Buffer name matching
You can also match buffers by name (useful for special buffers like *scratch* or *Messages*):
;; Match specific buffer names
(setq cloak-mode-patterns '(("*scratch*" . "[a-zA-Z0-9_]+=\\(.*\\)")))
;; Mixed: major mode and buffer name
(setq cloak-mode-patterns '((envrc-file-mode . "[a-zA-Z0-9_]+=[ \t]*\\(.*\\)$")
("*scratch*" . "[a-zA-Z0-9_]+=\\(.*\\)")))
;; Multiple patterns per buffer name
(setq cloak-mode-patterns '(("*scratch*" . ("pattern1" "pattern2"))))
