complete-computing-environment/doom_modeline.org

71 lines
3.3 KiB
Org Mode

:PROPERTIES:
:ID: cce/doom_modeline
:END:
#+TITLE: Doom Modeline
#+filetags: :Emacs:CCE:
#+PROPERTY: header-args :mkdirp yes :results none
#+PROPERTY: header-args:emacs-lisp :tangle doom-modeline.el
#+ARROYO_EMACS_MODULE: doom-modeline
#+ARCOLOGY_KEY: cce/doom-modeline
#+ARROYO_MODULE_WANTS: cce/configure_packaging.org
#+ARCOLOGY_ALLOW_CRAWL: t
#+begin_src emacs-lisp
(provide 'cce/doom-modeline)
#+end_src
I'm trying something new, coming back to a modeline customization suite. This time, we find ourselves with the [[https://github.com/seagle0128/doom-modeline][Doom Mode Line]], which I use in a pretty "out of the box" configuration for now. I add icon representations for [[id:cce/exwm][EXWM]] buffers so that they're not just default "document" icons.
#+begin_src emacs-lisp :noweb yes
(use-package nerd-icons)
(use-package doom-modeline
:after nerd-icons
:custom
(nerd-icons-font-family "Symbols Nerd Font Mono")
:config
(setq doom-modeline-unicode-fallback t
doom-modeline-enable-word-count nil
doom-modeline-minor-modes t)
(doom-modeline-mode 1)
(add-to-list 'nerd-icons-mode-icon-alist
'(exwm-mode nerd-icons-faicon "nf-fa-desktop"
:height 1.0 :face all-the-icons-purple))
<<org-titles-modeline>>
)
#+end_src
* [[id:cce/org-roam][org-roam]] buffer titles in Doom Modeline
:PROPERTIES:
:ID: 20230717T093538.797067
:END:
This function overrides/extends the function which Doom Modeline uses to set the buffer title in the modeline. It queries the [[id:cce/org-roam][org-roam]] database for the file's title, and falls back to the ='auto= [[help:doom-modeline-buffer-file-name-style]] if there isn't one.
#+begin_src emacs-lisp :noweb-ref org-titles-modeline
(defun doom-modeline-buffer-file-name ()
"Propertize file name based on `doom-modeline-buffer-file-name-style'."
(let* ((buffer-file-name (file-local-name (or (buffer-file-name (buffer-base-buffer)) "")))
(buffer-file-truename (file-local-name
(or buffer-file-truename (file-truename buffer-file-name) "")))
(file-name
(when (equal major-mode 'org-mode)
(caar (org-roam-db-query [:select title :from files :where (= file $s1)]
(buffer-file-name)))))
(file-name-fallback
(if (doom-modeline-project-p)
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shrink 'hide)
(propertize "%b" 'face 'doom-modeline-buffer-file)))
(file-name
(propertize (or file-name file-name-fallback) 'face 'doom-modeline-buffer-file)))
(propertize (if (string-empty-p file-name)
(propertize "%b" 'face 'doom-modeline-buffer-file)
file-name)
'mouse-face 'mode-line-highlight
'help-echo (concat buffer-file-truename
(unless (string= (file-name-nondirectory buffer-file-truename)
(buffer-name))
(concat "\n" (buffer-name)))
"\nmouse-1: Previous buffer\nmouse-3: Next buffer")
'local-map mode-line-buffer-identification-keymap)))
#+end_src