I have (setq global-linum-mode t) in my .emacs and I enable line number mode with M-x line-number-mode but still there are no line numbers on the margin. What am I doing wrong? I am on OS X and Emacs v. 24.3.

  • 1
    M-x linum-mode The modeline uses line-number-mode. I prefer to disable global stuff and use mode hooks instead -- e.g., (add-hook 'text-mode-hook (lambda () (linum-mode 1))) – lawlist Dec 29 '13 at 3:22
  • @lawlist Thanks! M-x linum-mode works without adding the mode hook. Actually, would it be possible to turn the line numbering on only with .clj files. I see that .clj files open in (Clojure Paredit Fill) mode. I haven't tried it but can it be something like (add-hook 'clojure-mode-hook (lambda () (linum-mode 1))) – Zeynel Dec 29 '13 at 10:45
  • 1
    Yes, that is the advantage of removing the global stuff -- you can make it apply only to a specific mode. Just comment out your (setq global-linum-mode t). – lawlist Dec 29 '13 at 16:08

Looking at the documentation for the variable global-linum-mode has the answer to your problem:

Setting this variable directly does not take effect; either customize it (see the info node Easy Customization') or call the functionglobal-linum-mode'.

So evaluating (setq global-linum-mode t) will not cause linum-mode to be turned on for all buffers. You would evaluate (global-linum-mode) to do that.

You are correct in your comment above that to turn on linum-mode only for certain modes you would evaluate (add-hook 'clojure-mode-hook linum-mode) (using clojure-mode for example).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.