Skip to content

Commit

Permalink
Add customization for God mode's minor mode lighter (#151)
Browse files Browse the repository at this point in the history
Add customization for lighter

Add a face for the lighter, and allow the lighter string to be
customized.  Also update README describing these customizations.
  • Loading branch information
luispauloml committed Dec 30, 2022
1 parent 23bb1e2 commit 607aff1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/README.md
Expand Up @@ -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 this using `M-x customize-face RET god-mode-lighter` or as follows:

```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
Expand Down
16 changes: 15 additions & 1 deletion god-mode.el
Expand Up @@ -109,6 +109,18 @@ in God mode will be translated to `C-<f5>'."
: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'."
Expand All @@ -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)
Expand Down

0 comments on commit 607aff1

Please sign in to comment.