From 8124b717c2eae65b34957c9833dcd8908c1ca6f9 Mon Sep 17 00:00:00 2001 From: Protesilaos Stavrou Date: Thu, 18 Apr 2024 08:46:43 +0300 Subject: [PATCH] emacs: convert all mode line settings to use-package I am doing this for the entirety of my setup, to be aligned with the de facto standard. --- .../prot-emacs-modules/prot-emacs-modeline.el | 15 +++--- emacs/.emacs.d/prot-emacs.org | 51 ++++++++++--------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/emacs/.emacs.d/prot-emacs-modules/prot-emacs-modeline.el b/emacs/.emacs.d/prot-emacs-modules/prot-emacs-modeline.el index 5e5c76f9..f9e73194 100644 --- a/emacs/.emacs.d/prot-emacs-modules/prot-emacs-modeline.el +++ b/emacs/.emacs.d/prot-emacs-modules/prot-emacs-modeline.el @@ -1,6 +1,7 @@ ;;; Mode line -(prot-emacs-package prot-modeline - (:delay 1) +(use-package prot-modeline + :ensure nil + :config (setq mode-line-compact nil) ; Emacs 28 (setq mode-line-right-align-edge 'right-margin) ; Emacs 30 (setq-default mode-line-format @@ -41,14 +42,16 @@ (add-hook 'spacious-padding-mode-hook #'prot/modeline-spacious-indicators))) ;;; Keycast mode -(prot-emacs-package keycast - (:install t) - (:delay 5) +(use-package keycast + :ensure t + :after prot-modeline + :commands (keycast-mode-line-mode keycast-header-line-mode keycast-tab-bar-mode keycast-log-mode) + :init (setq keycast-mode-line-format "%2s%k%c%R") (setq keycast-mode-line-insert-after 'prot-modeline-vc-branch) (setq keycast-mode-line-window-predicate 'mode-line-window-selected-p) (setq keycast-mode-line-remove-tail-elements nil) - + :config (dolist (input '(self-insert-command org-self-insert-command)) (add-to-list 'keycast-substitute-alist `(,input "." "Typing…"))) diff --git a/emacs/.emacs.d/prot-emacs.org b/emacs/.emacs.d/prot-emacs.org index 299ec141..2ae4b6c1 100644 --- a/emacs/.emacs.d/prot-emacs.org +++ b/emacs/.emacs.d/prot-emacs.org @@ -3751,10 +3751,19 @@ Notice the use of ~setq-default~. This is like ~setq~ but sets the default value of variable that normally are buffer-local. You will only find a few cases where this is needed. +In this section I also take care to provide integration with my +~spacious-padding~ package ([[#h:6c118185-fcb1-4c9a-93af-71814cb84279][The =prot-emacs-theme.el= section for ~spacious-padding~]]). +It adds, among others, a box effect to mode line constructs. +To make the faces of ~prot-modeline.el~ look right in this scenario, I +add a box to them as well. They then adopt whatever padding is there. +The ~with-eval-after-load~ pattern is how to evaluate some code +as soon as the given package/feature is loaded. + #+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-modeline.el" :mkdirp yes ;;; Mode line -(prot-emacs-package prot-modeline - (:delay 1) +(use-package prot-modeline + :ensure nil + :config (setq mode-line-compact nil) ; Emacs 28 (setq mode-line-right-align-edge 'right-margin) ; Emacs 30 (setq-default mode-line-format @@ -3780,23 +3789,7 @@ only find a few cases where this is needed. prot-modeline-notmuch-indicator " " prot-modeline-misc-info)) -#+end_src -*** The =prot-emacs-modeline.el= integration with ~spacious-padding~ -:PROPERTIES: -:CUSTOM_ID: h:30bfbf81-a5ad-44af-a91b-6b8dd37ff789 -:END: - -My ~spacious-padding~ package adds, among others, a box effect to mode -line constructs ([[#h:6c118185-fcb1-4c9a-93af-71814cb84279][The =prot-emacs-theme.el= section for ~spacious-padding~]]). - -To make the faces of ~prot-modeline.el~ look right in this scenario, I -add a box to them as well. They then adopt whatever padding is there. - -The ~with-eval-after-load~ pattern is a nice way to evaluate some code -as soon as the given package/feature is loaded. - -#+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-modeline.el" :mkdirp yes (with-eval-after-load 'spacious-padding (defun prot/modeline-spacious-indicators () "Set box attribute to `'prot-modeline-indicator-button' if spacious-padding is enabled." @@ -3826,23 +3819,35 @@ shows an indicator on the focused mode line. Note that the value of ~keycast-mode-line-insert-after~ only works with my customised mode line ([[#h:41ee38d0-9099-4444-85e4-cc8dce00fb9a][The =prot-emacs-modeline.el= module]]). -#+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-modeline.el" :mkdirp yes +#+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-modeline.el" ;;; Keycast mode -(prot-emacs-package keycast - (:install t) - (:delay 5) +(use-package keycast + :ensure t + :after prot-modeline + :commands (keycast-mode-line-mode keycast-header-line-mode keycast-tab-bar-mode keycast-log-mode) + :init (setq keycast-mode-line-format "%2s%k%c%R") (setq keycast-mode-line-insert-after 'prot-modeline-vc-branch) (setq keycast-mode-line-window-predicate 'mode-line-window-selected-p) (setq keycast-mode-line-remove-tail-elements nil) - + :config (dolist (input '(self-insert-command org-self-insert-command)) (add-to-list 'keycast-substitute-alist `(,input "." "Typing…"))) (dolist (event '( mouse-event-p mouse-movement-p mwheel-scroll handle-select-window mouse-set-point mouse-drag-region)) (add-to-list 'keycast-substitute-alist `(,event nil)))) +#+end_src +*** The =prot-emacs-essentials.el= call to ~provide~ +:PROPERTIES: +:CUSTOM_ID: h:be07591f-6130-4641-9f06-a634f21bb2f6 +:END: + +Finally, we ~provide~ the module. This is the mirror function of +~require~ ([[#h:e6c4acf5-5b51-4b38-a86a-bf3f698ac872][The init.el final part to load the individual modules]]). + +#+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-modeline.el" (provide 'prot-emacs-modeline) #+end_src