summary refs log tree commit diff stats
path: root/lisp/+nyan-mode.el
blob: 33ae9aff0c673abe3974b72a03763784c7584037 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;;; +nyan-mode.el --- Extras for nyan-mode -*- lexical-binding: t; -*-

;;; Commentary:

;;; Code:

;;; Update even without line number in the mode line.

(defcustom +nyan-mode-update-functions
  '( end-of-buffer beginning-of-buffer
     next-line previous-line
     org-next-visible-heading org-previous-visible-heading)
  "Functions after which to force a mode-line update."
  :type '(repeat function))

(defun +nyan-mode--fmlu (&rest _)
  "Update the mode-line, advice-style."
  (force-mode-line-update))

(defun +nyan-mode-advice (&rest _)
  "Advise line-moving functions when in `nyan-mode'."
  (dolist (fn +nyan-mode-update-functions)
    (if nyan-mode
        (advice-add fn :after #'+nyan-mode--fmlu)
      (advice-remove fn #'+nyan-mode--fmlu))))

(defface +nyan-mode-line nil
  "Face for the nyan-mode mode-line indicator.")

(define-minor-mode +nyan-local-mode
  "My very own `nyan-mode' that isn't global and doesn't update the mode-line."
  :global nil
  :group 'nyan
  (dolist (fn +nyan-mode-update-functions)
    (if +nyan-local-mode
        (advice-add fn :after #'+nyan-mode--fmlu)
      (advice-remove fn #'+nyan-mode--fmlu))))

(define-globalized-minor-mode +nyan-mode +nyan-local-mode +nyan-local-mode)

(provide '+nyan-mode)
;;; +nyan-mode.el ends here