summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-21 12:36:04 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-10-21 12:36:04 +0200
commitdd51bdefb6fed6b89d34d8b195f4cc55c01a055f (patch)
tree0ec2c72fdbde9d57216a8d4ad5a599336b0bd582 /.config
parent01b13d18c60092edd23a4ef118de67c7c01c7c79 (diff)
emacs: Improve modeline major-mode name generation
Diffstat (limited to '.config')
-rw-r--r--.config/emacs/modules/mm-modeline.el33
1 files changed, 21 insertions, 12 deletions
diff --git a/.config/emacs/modules/mm-modeline.el b/.config/emacs/modules/mm-modeline.el
index a3545cc..ce28d69 100644
--- a/.config/emacs/modules/mm-modeline.el
+++ b/.config/emacs/modules/mm-modeline.el
@@ -48,22 +48,31 @@
'("css" "csv" "gsp" "html" "json" "mhtml" "scss" "toml" "tsv")
"TODO")
+(defconst mm-modeline-remap-alist
+ '(("Js" . "JavaScript")
+ ("Ts Mode" . "Tree-Sitter Mode")
+ ("Gmake" . "GMake")
+ ("Imake" . "IMake")
+ ("Bsdmake" . "BSD Make"))
+ "TODO")
+
(mm-modeline--define-component mm-modeline-major-mode-name
(propertize
- (let ((string
- (thread-last
- major-mode
- (symbol-name)
- (capitalize)
- (string-replace "-" " ")
- ;; TODO: Make a remap alist
- (replace-regexp-in-string "\\<Js\\>" "JavaScript")
- (string-replace "Ts Mode" "Tree-Sitter Mode")))
- (case-fold-search t))
+ (let ((string (thread-last
+ major-mode
+ (symbol-name)
+ (capitalize)
+ (string-replace "-" " ")))
+ (case-fold-search nil))
;; TODO: Do I need ‘save-match-data’
(save-match-data
- (if (string-match
- (concat "\\<" (regexp-opt mm-modeline-mode-acronyms) "\\>") string)
+ (dolist (pair mm-modeline-remap-alist)
+ (setq string
+ (replace-regexp-in-string
+ (format "\\<%s\\>" (regexp-quote (car pair)))
+ (cdr pair) string)))
+ (setq case-fold-search t)
+ (if (string-match (regexp-opt mm-modeline-mode-acronyms 'words) string)
(concat
(substring string 0 (match-beginning 0))
(upcase (substring string (match-beginning 0) (match-end 0)))