From af3eb37c8e51084261f2ad4bfe1d36fffbcfaebf Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 8 Jun 2022 17:59:53 -0500 Subject: blep --- lisp/+nyan-mode.el | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lisp/+nyan-mode.el (limited to 'lisp/+nyan-mode.el') diff --git a/lisp/+nyan-mode.el b/lisp/+nyan-mode.el new file mode 100644 index 0000000..fc6775b --- /dev/null +++ b/lisp/+nyan-mode.el @@ -0,0 +1,39 @@ +;;; +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)))) + +(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 -- cgit 1.4.1-21-gabe81