forked from redguardtoo/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-linum-mode.el
69 lines (65 loc) · 3.34 KB
/
init-linum-mode.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
58
59
60
61
62
63
64
65
66
67
68
69
;; http://stackoverflow.com/questions/3875213/turning-on-linum-mode-when-in-python-c-mode
(setq linum-mode-inhibit-modes-list '(eshell-mode
shell-mode
profiler-report-mode
ffip-diff-mode
dictionary-mode
erc-mode
browse-kill-ring-mode
dired-mode
help-mode
text-mode
fundamental-mode
jabber-roster-mode
jabber-chat-mode
inferior-js-mode
inferior-python-mode
inferior-scheme-mode
ivy-occur-grep-mode ; better performance
ivy-occur-mode ; better performance
twittering-mode
compilation-mode
weibo-timeline-mode
woman-mode
Info-mode
calc-mode
calc-trail-mode
comint-mode
gnus-group-mode
inf-ruby-mode
gud-mode
org-mode
vc-git-log-edit-mode
log-edit-mode
term-mode
w3m-mode
speedbar-mode
gnus-summary-mode
gnus-article-mode
calendar-mode))
(cond
((fboundp 'global-display-line-numbers-mode)
(defun display-line-numbers-mode-hook-setup ()
(setq display-line-numbers (if (or (memq major-mode linum-mode-inhibit-modes-list)
;; don't show line number for certain file extensions
(should-use-minimum-resource))
nil
t)))
(add-hook 'display-line-numbers-mode-hook 'display-line-numbers-mode-hook-setup)
(global-display-line-numbers-mode t))
(t
(global-linum-mode t)
(defadvice linum-on (around linum-on-inhibit-for-modes)
"Stop the load of linum-mode for some major modes."
(unless (member major-mode linum-mode-inhibit-modes-list)
ad-do-it))
(ad-activate 'linum-on)
;; update line number every second so `linum-mode' won't slow down Emacs
;; @see https://lists.gnu.org/archive/html/bug-gnu-emacs/2013-04/msg00577.html
;; package like `nlinum-mode' has better performance but `git-gutter' is dependent
;; on `linum-mode'.
;; So we have to use `linum-mode'.
(setq linum-delay t)
(defadvice linum-schedule (around my-linum-schedule () activate)
(run-with-idle-timer 1 nil #'linum-update-current))))
(provide 'init-linum-mode)