summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/mm-modeline.el
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-17 13:37:43 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-10-17 13:37:43 +0200
commit952d011ef733986aa8ac77c18cac87325dc09f0e (patch)
tree564e98de8df9427118d842b891b5e74e38380c17 /.config/emacs/modules/mm-modeline.el
parent363a7774f54c0a3d03ae01431c07bcd78e991177 (diff)
emacs: Make the modeline mode display better
Diffstat (limited to '.config/emacs/modules/mm-modeline.el')
-rw-r--r--.config/emacs/modules/mm-modeline.el34
1 files changed, 23 insertions, 11 deletions
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\\>" "TOML")
- (replace-regexp-in-string "\\<gsp\\>" "GSP"))
+ (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))
+ ;; 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