Since doc-view-mode
is very slow with the enabled linum-mode
, I am trying to disable it for that mode. The same question has been answered almost 6 years ago:
automatically disable a global minor mode for a specific major mode
Following the answer of phils, I have put the following in my .emacs file:
(define-global-minor-mode my-global-linum-mode global-linum-mode
(lambda ()
(when (not (memq major-mode
(list 'doc-view-mode 'shell-mode)))
(global-linum-mode))))
(my-global-linum-mode 1)
(add-hook 'doc-view-mode-hook 'my-inhibit-global-linum-mode)
(defun my-inhibit-global-linum-mode ()
"Counter-act `global-linum-mode'."
(add-hook 'after-change-major-mode-hook
(lambda () (linum-mode 0))
:append :local))
The problem is that I cannot make it work permanently. When I start a new buffer, the line numbers reappear in the buffer of doc-view-mode
. Please help!