X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/1865c0d5599d12cb42814941ccba77b0fc070cab..d31e024cc98d37700879d4c8675fd10e678e44c1:/delight.el diff --git a/delight.el b/delight.el index 8e88e2eb2..ba693c4ad 100644 --- a/delight.el +++ b/delight.el @@ -2,7 +2,16 @@ ;; ;; Author: Phil S. ;; URL: http://www.emacswiki.org/emacs/DelightedModes -;; Version: 1.03 +;; Keywords: convenience +;; Created: 25 Jun 2013 +;; Version: 1.05 + +;; This file is not part of GNU Emacs. + +;; This file is free software: you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free Software +;; Foundation, either version 3 of the License, or (at your option) any later +;; version. See . ;;; Commentary: ;; @@ -21,8 +30,30 @@ ;; (smart-tab-mode " \\t" "smart-tab") ;; (eldoc-mode nil "eldoc") ;; (rainbow-mode) +;; (overwrite-mode " Ov" t) ;; (emacs-lisp-mode "Elisp" :major))) ;; +;; The first argument is the mode symbol. +;; +;; The second argument is the replacement name to use in the mode line +;; (or nil to hide it). +;; +;; The third argument is either the keyword :major for major modes or, +;; for minor modes, the library which defines the mode. This is passed +;; to ‘eval-after-load’ and so should be either the name (as a string) +;; of the library file which defines the mode, or the feature (symbol) +;; provided by that library. If this argument is nil, the mode symbol +;; will be passed as the feature. If this argument is either t or 'emacs +;; then it is assumed that the mode is already loaded (you can use this +;; with standard minor modes that are pre-loaded by default when Emacs +;; starts). +;; +;; To determine which library defines a mode, use e.g.: C-h f +;; eldoc-mode RET. The name of the library is displayed in the first +;; paragraph, with an “.el” suffix (in this example it displays +;; “eldoc.el”, and therefore we could use the value “eldoc” for the +;; library). +;; ;; Important note: ;; ;; Although strings are common, any mode-line construct is permitted @@ -50,8 +81,11 @@ ;; you change the sorting criteria) in which cases this library may ;; prove inadequate. -;;; Changelog: +;;; Change Log: ;; +;; 1.05 (2016-03-01) Support FILE value t, meaning that the minor MODE +;; in question is guaranteed to already be loaded. +;; 1.04 (2016-02-28) Respect `inhibit-mode-name-delight' when already set. ;; 1.03 (2014-05-30) Added support for `mode-line-mode-menu'. ;; 1.02 (2014-05-04) Bug fix for missing 'cl requirement for ;; destructuring-bind macro. @@ -88,8 +122,9 @@ mode-line construct. For details see the `mode-line-format' variable, and Info node `(elisp) Mode Line Format'. The FILE argument is passed through to `eval-after-load'. If FILE is nil then -the mode symbol is passed as the required feature. Both of these cases are -relevant to minor modes only. +the mode symbol is passed as the required feature. If FILE is t then it is +assumed that the mode is already loaded. (Note that you can also use 'emacs +for this purpose). These FILE options are relevant to minor modes only. For major modes you should specify the keyword :major as the value of FILE, to prevent the mode being treated as a minor mode." @@ -100,7 +135,7 @@ to prevent the mode being treated as a minor mode." (assq-delete-all mode delighted-modes) (add-to-list 'delighted-modes (list mode value file)) (unless (eq file :major) - (eval-after-load (or file mode) + (eval-after-load (if (eq file t) 'emacs (or file mode)) `(let ((minor-delight (assq ',mode minor-mode-alist))) (when minor-delight (setcar (cdr minor-delight) ',value) @@ -156,10 +191,14 @@ When `mode-name' is displayed in other contexts (such as in the ,mode-name ;; glum ,(cadr major-delight)))))) ;; delighted +(defvar inhibit-mode-name-delight) + (defadvice format-mode-line (around delighted-modes-are-glum activate) "Delighted modes should exhibit their original `mode-name' when `format-mode-line' is called. See `delight-major-mode'." - (let ((inhibit-mode-name-delight t)) + (let ((inhibit-mode-name-delight (if (boundp 'inhibit-mode-name-delight) + inhibit-mode-name-delight + t))) ad-do-it)) (provide 'delight)