I want to turn on linum mode (M-x linum-mode) automatically with python and c mode. I add the following code in .emacs, but it doesn't seem to work.
(defun my-c-mode-common-hook ()
(line-number-mode 1))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(defun my-python-mode-common-hook ()
(line-number-mode 1))
(add-hook 'python-mode-common-hook 'my-python-mode-common-hook)
What might be wrong?
You also have the option of setting linum-mode globally.
;; In your .emacs
(global-linum-mode 1)
Edit:
In my configuration I have global-linum-mode
active and inhibit it for certain major modes:
(setq linum-mode-inhibit-modes-list '(eshell-mode
shell-mode
erc-mode
jabber-roster-mode
jabber-chat-mode
gnus-group-mode
gnus-summary-mode
gnus-article-mode))
(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)
line-number-mode
and linum-mode
are not the same.
Try this:
(defun my-c-mode-hook ()
(linum-mode 1))
(add-hook 'c-mode-hook 'my-c-mode-hook)
(defun my-python-mode-hook ()
(linum-mode 1))
(add-hook 'python-mode-hook 'my-python-mode-hook)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With