Closed joe9 closed 9 years ago
I have seen issues with global-nlinum-mode
and emacs daemon mode which I haven't yet got chance to debug.
But the below works as of today:
I have this in my init.el:
If you want, you can use stuff from my setup-linum.el
. The linum setup looks complicated because I wanted a clean way to switch between linum packages: nlinum
, linum
and linum-relative
. But the crucial piece of code in there that might be useful to you is how to set the linum/nlinum mode only for your selected major modes.
(defconst modi/linum-mode-hooks '(verilog-mode-hook
emacs-lisp-mode-hook
cperl-mode-hook
c-mode-hook
python-mode-hook
matlab-mode-hook
sh-mode-hook
web-mode-hook
html-mode-hook
css-mode-hook
makefile-gmake-mode-hook
tcl-mode-hook)
"List of hooks of major modes in which a linum mode should be enabled.")
Here's the relevant piece that enable nlinum only for those modes:
(when global-linum-mode
(global-nlinum-mode -1))
(dolist (hook modi/linum-mode-hooks)
(add-hook hook #'nlinum-mode))
As I mentioned, I need to look into why global enabling of nlinum/linum doesn't work in daemon mode.
I'll keep this issue open till we find a solution to be able to successfully start emacs in daemon mode with nlinum enabled globally.
But in the meanwhile, let me know if the daemon startup issue is resolved for you if you enable nlinum only for selected major modes using their hooks.
@joe9 Feel free to test out this method of linum activation. It now works fine for me on both emacs and emacsclient.
Delay the loading of linum to 1 second after emacs becomes idle (after setting up the frame, etc). So it does not matter if you are starting emacs or emacsclient.
Load the desktop only after linum has loaded. The problem earlier was that if your saved desktop had references to file buffers that had linum on at the time of saving the desktop, emacs would try to enable linum mode for those buffers even before linum was enabled or loaded. This solution makes sure that linum is loaded before the desktop is loaded.
@joe9 I am closing this issue as I have tested global linum mode to work fine in an emacs daemon session now. Feel free to reopen it if you still see this problem.
Thanks for fixing this.
Sounds great.
Does it work for splitting out a new frame (C-x 5 2
)? My current setup (not derived from this code) allows for normal startup, but opening a new frame fails. I wonder if you've overcome this issue.
I use a single frame workflow. So I never needed to do C-x 5 2
. But the good news is that this delaying trick works for that too :)
Here's how I quickly tested the code by modifying my code at this line:
;; Do desktop setup after linum setup so that the desktop loaded files will show
;; linum if enabled for that major mode or if enabled globally
(with-eval-after-load 'setup-linum
(require 'setup-desktop)
(make-frame-command))
Nice to know! Thanks for the code.
Just FYI, the same code might not work for you if you haven't delayed loading setup-linum
as I have.
following piece code worked for me.
(defun initialize-nlinum (&optional frame)
(require 'nlinum)
(add-hook 'prog-mode-hook 'nlinum-mode))
(when (daemonp)
(add-hook 'window-setup-hook 'initialize-nlinum)
(defadvice make-frame (around toggle-nlinum-mode compile activate)
(nlinum-mode -1) ad-do-it (nlinum-mode 1)))
Those code make my emacs 24.5.1 daemon mode worked with nlinum-mode very well. No matter what open a frame from terminal or create a new frame in emacs.
Thanks for sharing that. Since I posted the last time in this thread, I have made a big improvement in how to deal with daemon and linum/font-checking/etc.
Solution: Start linum/nlinum in after-make-frame-functions
when (daemonp)
.
Code: https://github.com/kaushalmodi/.emacs.d/blob/c5a7d1a9c0aba5c80fac7be87ece0afffc51099b/setup-files/setup-linum.el#L166-L178
Hello,
I am sorry to raise this here.
I am trying to use the fix recommended by you here: http://debbugs.gnu.org/cgi/bugreport.cgi?msg=43;att=1;bug=18616
But, for some reason, nothing happens when I start emacs in daemon mode with that code snippet in my init.el. I am using GNU Emacs 24.4.1
Just want to check if the relevant code snippet is still valid.
Thanks again and Sorry for the bother,
This is the code snippet of what I tried: