-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmode-line-major.el
57 lines (48 loc) · 1.48 KB
/
mode-line-major.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;;; mode-line-major.el -- Hide minor modes from the mode-line
;;; About
;;
;; Remove all minor-modes from the mode-line.
;;
;; This will ensure that only major modes are present, as well as any
;; line/columns the user prefers.
;;
;;; Installation
;;
;; Ensure this file is somewhere upon your load-path, then enable
;;
;; (require 'mode-line-major)
;;
;; If you're using `use-package' then you can achieve the same effect
;; with:
;;
;; (use-package mode-line-major)
;;
;; In either case that is all you need to do, there are zero configuration
;; options supported by this package.
;;
(defun mode-line-major--minor-modes ()
"Get a list of which minor modes which are available."
(let ($list)
(mapc (lambda ($mode)
(condition-case nil
(if (symbolp $mode)
(setq $list (cons $mode $list)))
(error nil)))
minor-mode-list)
(sort $list 'string<)))
(defun mode-line-major-cleanup ()
"Remove all minor-modes from the mode-line.
The end result will be keeping only the major-modes."
(interactive)
(mapc
(lambda (mode)
(let* ((old-mode-str (cdr (assq mode minor-mode-alist))))
(when old-mode-str
(setcar old-mode-str ""))
(when (eq mode major-mode)
(setq mode-name mode-str))))
(mode-line-major--minor-modes)))
;; Ensure that we're enabled
(add-hook 'after-change-major-mode-hook 'mode-line-major-cleanup)
;; Provide the package
(provide 'mode-line-major)