From bf20cbea4b71e740fd5d43a217f2ee7721172423 Mon Sep 17 00:00:00 2001 From: "Luis Paulo M. Lima" Date: Sun, 25 Dec 2022 22:14:30 +0900 Subject: [PATCH 1/2] Add customization for lighter Add a face for the lighter, and allow the lighter string to be customized. Also update README describing these customizations. --- .github/README.md | 12 +++++++++++- god-mode.el | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/README.md b/.github/README.md index 94e1e54..74ebaf0 100644 --- a/.github/README.md +++ b/.github/README.md @@ -159,7 +159,17 @@ Note that `god-mode-describe-key` is only able to interpret key-bindings that ar ## Visual indicators for God mode -You can change the cursor style to visually indicate whether God mode is active +God mode allows you to customize its minor mode lighter by customizing the `god-mode-lighter-string` variable and the `god-mode-lighter` face. +For example, if you don't want any lighter, you can set the string to nil. +On the other hand, if you want the lighter to stand out, you can change the face, e.g. by making it inherit from `error`. +You can do the latter via `M-x customize-face RET god-mode-ligher` or via Lisp: + +```emacs-lisp +(custom-set-faces + '(god-mode-lighter ((t (:inherit error))))) +``` + +Additionally, you can change the cursor style to visually indicate whether God mode is active as follows: ```emacs-lisp diff --git a/god-mode.el b/god-mode.el index 88629a8..e4c1abc 100644 --- a/god-mode.el +++ b/god-mode.el @@ -109,6 +109,18 @@ in God mode will be translated to `C-'." :group 'god :type 'boolean) +(defcustom god-mode-lighter-string + "God" + "String displayed on the mode line when God mode is active. +Set it to nil if you don't want a mode line indicator." + :group 'god + :type '(choice string (const :tag "None" nil))) + +(defface god-mode-lighter + '((t)) + "Face for God mode's lighter." + :group 'god) + (defun god-mode-make-f-key (n &optional shift) "Get the event for numbered function key N, with shift status SHIFT. For example, calling with arguments 5 and t yields the symbol `S-f5'." @@ -134,7 +146,9 @@ For example, calling with arguments 5 and t yields the symbol `S-f5'." (define-minor-mode god-local-mode "Minor mode for running commands." :init-value nil - :lighter " God" + :lighter (god-mode-lighter-string + ((" " + (:propertize god-mode-lighter-string face god-mode-lighter)))) :keymap god-local-mode-map (if god-local-mode (run-hooks 'god-mode-enabled-hook) From dcfd260eafde158debe7b58a9f950c03d90bec6d Mon Sep 17 00:00:00 2001 From: "Luis Paulo M. Lima" Date: Fri, 30 Dec 2022 14:38:12 +0900 Subject: [PATCH 2/2] Update README and indentation --- .github/README.md | 2 +- god-mode.el | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index 74ebaf0..04733e8 100644 --- a/.github/README.md +++ b/.github/README.md @@ -162,7 +162,7 @@ Note that `god-mode-describe-key` is only able to interpret key-bindings that ar God mode allows you to customize its minor mode lighter by customizing the `god-mode-lighter-string` variable and the `god-mode-lighter` face. For example, if you don't want any lighter, you can set the string to nil. On the other hand, if you want the lighter to stand out, you can change the face, e.g. by making it inherit from `error`. -You can do the latter via `M-x customize-face RET god-mode-ligher` or via Lisp: +You can do this using `M-x customize-face RET god-mode-lighter` or as follows: ```emacs-lisp (custom-set-faces diff --git a/god-mode.el b/god-mode.el index e4c1abc..2b54539 100644 --- a/god-mode.el +++ b/god-mode.el @@ -147,8 +147,8 @@ For example, calling with arguments 5 and t yields the symbol `S-f5'." "Minor mode for running commands." :init-value nil :lighter (god-mode-lighter-string - ((" " - (:propertize god-mode-lighter-string face god-mode-lighter)))) + ((" " + (:propertize god-mode-lighter-string face god-mode-lighter)))) :keymap god-local-mode-map (if god-local-mode (run-hooks 'god-mode-enabled-hook)