开发者

emacs minor mode for temporarily modifying the default face

For example, how can I make a minor mode that changes the default foreground color to gray, and upon e开发者_如何学Cxiting the minor mode, the foreground color is back to black? This mode might be useful when you don't like certain text to be seen over your shoulders.

For now, I run the following code to turn text color to gray:

(set-face-attribute 'default (selected-frame) :foreground "darkgrey")

And the following code to get back.

(set-face-attribute 'default (selected-frame) :foreground "SystemWindowText")

But this affects all buffers.


You can use buffer-face-mode based on overlays, it also lets to change the background of text in your buffer.

(make-face 'hard-to-read-font)
(set-face-attribute 'hard-to-read-font nil :background "darkgrey" :foreground "grey")

(define-minor-mode hard-to-read-mode
  "This mode might be useful when you don't like certain text to be seen over your shoulders."
  :init-value nil :lighter " hard-to-read" :keymap nil
  (if hard-to-read-mode
      (progn
        (font-lock-mode nil)
        (buffer-face-mode t)
        (buffer-face-set 'hard-to-read-font))
    (progn
      (font-lock-mode t)
      (buffer-face-mode nil))))

;; change this to mode you need
;; or turn it on manually
;; (add-hook 'text-mode-hook
;;           (lambda ()
;;             (hard-to-read-mode t)))

update: You know, this isn't secure. It works against human eyes, but anyone can use camera and then just increase contrast to read the text.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜