From 952d011ef733986aa8ac77c18cac87325dc09f0e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 17 Oct 2024 13:37:43 +0200 Subject: emacs: Make the modeline mode display better --- .config/emacs/modules/mm-modeline.el | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to '.config/emacs') diff --git a/.config/emacs/modules/mm-modeline.el b/.config/emacs/modules/mm-modeline.el index cd9af3e..7ca4751 100644 --- a/.config/emacs/modules/mm-modeline.el +++ b/.config/emacs/modules/mm-modeline.el @@ -44,19 +44,31 @@ (buffer-file-name)) (propertize " (modified)" 'face 'shadow))) +(defconst mm-modeline-mode-acronyms + '("css" "csv" "gsp" "html" "json" "mhtml" "scss" "toml" "tsv") + "TODO") + (mm-modeline--define-component mm-modeline-major-mode-name (propertize - (thread-last - major-mode - (symbol-name) - (capitalize) - (string-replace "-" " ") - (string-replace "Ts Mode" "Tree-Sitter Mode") - ;; Casing doesn’t work for abbreviations, so fix it manually - (replace-regexp-in-string "\\<\\(M\\)?html\\>" "\\1HTML") - (replace-regexp-in-string "\\<\\(S\\)?css\\>" "\\1CSS") - (replace-regexp-in-string "\\" "TOML") - (replace-regexp-in-string "\\" "GSP")) + (let ((string + (thread-last + major-mode + (symbol-name) + (capitalize) + (string-replace "-" " ") + ;; TODO: Make a remap alist + (replace-regexp-in-string "\\" "JavaScript") + (string-replace "Ts Mode" "Tree-Sitter Mode"))) + (case-fold-search t)) + ;; TODO: Do I need ‘save-match-data’ + (save-match-data + (if (string-match + (concat "\\<" (regexp-opt mm-modeline-mode-acronyms) "\\>") string) + (concat + (substring string 0 (match-beginning 0)) + (upcase (substring string (match-beginning 0) (match-end 0))) + (substring string (match-end 0) (length string))) + string))) 'face 'bold)) (mm-modeline--define-component mm-modeline-major-mode-symbol -- cgit v1.2.3