From e8d454a251c20c9325b1d861e3147694fa18371f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 28 May 2017 16:12:28 +0200 Subject: [PATCH] Add doom-ui-mode-names for renaming major-modes --- TODO.org | 3 ++- core/core-ui.el | 13 +++++++++++++ modules/lang/emacs-lisp/config.el | 1 - modules/lang/sh/config.el | 4 +--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/TODO.org b/TODO.org index 187d575a6..c2bb5de45 100644 --- a/TODO.org +++ b/TODO.org @@ -92,7 +92,7 @@ + [ ] twitter + [ ] present -** 2.0.3 [53/81] +** 2.0.3 [54/82] + [2/3] Finish module :: feature/jump (go-to-definition that just works) + [ ] automatic tag generation + [X] global tags support @@ -133,6 +133,7 @@ + [ ] Fix invisible buffer-info segment in modeline for terminal Emacs + [ ] ui/doom-modeline: fix ~0/0~ display in modeline (leftover anzu state) + [ ] lang/php: automatic+async rebuild of tags (phpctags) ++ [X] Extract ~mode-name~ setters to ~doom-ui-mode-names~ in core/core-ui + [X] nav-flash: blink on focus-in + [X] Add ~:textobj~ keyword to ~map!~ + [X] Make ~doom-refresh-packages~ async diff --git a/core/core-ui.el b/core/core-ui.el index 5e93d4eed..5a03e9eb9 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -95,6 +95,19 @@ local value, whether or not it's permanent-local. Therefore, we cycle show-paren-when-point-inside-paren t) (show-paren-mode +1) +;; like diminish, but for major-modes. [pedantry intensifies] +(defvar doom-ui-mode-names + '((sh-mode . "sh") + (emacs-lisp-mode "Elisp")) + "An alist mapping major modes to alternative names, which will be set when the +mode is detected.") + +(defun doom|set-mode-name () + "Set the major mode's `mode-name', as dictated by `doom-ui-mode-names'." + (let ((name (assq major-mode doom-ui-mode-names))) + (if name (setq mode-name (cdr name))))) +(add-hook 'after-change-major-mode-hook #'doom|set-mode-name) + ;; ;; Bootstrap diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index fe8a17c48..411797add 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -21,7 +21,6 @@ (set! :editorconfig :remove 'emacs-lisp-mode) (defun +emacs-lisp|hook () - (setq mode-name "Elisp") ; [pedantry intensifies] (add-hook 'before-save-hook #'delete-trailing-whitespace nil t) (eldoc-mode +1) diff --git a/modules/lang/sh/config.el b/modules/lang/sh/config.el index dd636a916..fbacacf9d 100644 --- a/modules/lang/sh/config.el +++ b/modules/lang/sh/config.el @@ -10,9 +10,7 @@ (set! :repl 'sh-mode #'+sh/repl) (setq sh-indent-after-continuation 'always) - ;; [pedantry intensifies] - (add-hook! sh-mode (setq mode-name "sh")) - + ;; sh-mode has file extensions checks for other shells, but not zsh, so... (defun +sh|detect-zsh () (when (and buffer-file-name (string-match-p "\\.zsh\\'" buffer-file-name)) (sh-set-shell "zsh")))