-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializing under daemon? #3
Comments
I have tried:
When I start the first client frame, they run with |
It's probably not the most elegent solution, but I use an (defun my/init-fonts (&optional f)
(when (display-graphic-p f)
(unicode-fonts-setup)
;; anything else that needs fonts to be available
(remove-hook 'after-make-frame-functions 'my/init-fonts))))
(add-hook 'after-init-hook
(lambda ()
(if initial-window-system
(my/init-fonts)
(add-hook 'after-make-frame-functions 'my/init-fonts)))) the |
Nice. I wonder if it’s worthwhile deferring until |
Some more observations.
I worked around this by sticking a The resulting snippet looks like this: (defun my/init-fonts (&optional frame)
(when (display-graphic-p frame)
(select-frame frame)
(unicode-fonts-setup)
(remove-hook 'after-make-frame-functions 'my/init-fonts)))
(add-hook 'after-init-hook
(lambda ()
(if initial-window-system
(my/init-fonts)
(add-hook 'after-make-frame-functions 'my/init-fonts)))) |
Ah, good catch! I've just started trying out |
Is there a proposed patch? |
So far, we were just discussing workarounds. But I can prepare a patch that (a) fixes the “record that we have run but actually do nothing”, and/or (b) passes the frame as a parameter to |
One quick note: since |
I don't use daemon startup, so I'm inclined to take the advice of those that do so on how the fix should be implemented. The purpose of the library is purely convenience, so the goal should be that |
Hello, another user is now in the same position as I was a year and a half ago. I have updated the pull request #4 to the current master. |
Hi! Thanks for reviving. I forgot about this issue as I don't use --daemon startup and never got around to trying it. I will try out #4. Reading that Google Plus thread, I want to note that unicode-fonts startup is much faster now. If the user is seeing a five-second cost, he should upgrade. |
I have emacs 24.4.1
Otherwise it does not work. |
I’ve run into the same issue, five years later. @guraltsev’s code snippet solved the problem for me. I suggest this should be integrated into the package somehow. |
Is there any news on this. I have tried using the comment from @guraltsev and I have also installed used the 'fix-daemon-startup' branch from @yurikhan and that hasn't helped. This may be todo with the org-superstar plugin though |
(use-package unicode-fonts
:init (unicode-fonts//setup-fonts (selected-frame)))
(defun unicode-fonts//setup-fonts (frame)
"Setup `unicode-fonts' package for FRAME.
This functions setups `unicode-fonts' right away when starting a GUI Emacs.
But if Emacs is running in a daemon, it postpone the setup until a GUI frame
is opened."
(if (and frame (display-graphic-p frame))
(with-selected-frame frame
(require 'unicode-fonts)
(unicode-fonts-setup)
(remove-hook 'after-make-frame-functions #'unicode-fonts//setup-fonts))
(add-hook 'after-make-frame-functions #'unicode-fonts//setup-fonts))) I've come up with this solution. |
Based on the info in this thread, I've implemented the following macro in my config, which seems to work: (require 'cl)
(setq my/run-once-after-first-frame-counter 0)
(defmacro my/run-once-after-first-frame (&rest body)
`(lexical-let* (target-hook
(count my/run-once-after-first-frame-counter)
(fnsymb (make-symbol (format "my/run-once-after-first-frame-%d" count))))
(setq target-hook (if (daemonp)
'after-make-frame-functions
'after-init-hook))
(fset fnsymb (lambda (&optional frame)
(remove-hook target-hook fnsymb)
(when frame (select-frame frame))
,@body))
(add-hook target-hook fnsymb)
(cl-incf my/run-once-after-first-frame-counter))) Usage example: (my/run-once-after-first-frame
(unicode-fonts-setup)
;; Other commands go here, such as load-theme, etc...
) Also solves other problems such as this one. |
The readme says use
(unicode-fonts-setup)
in the init file. When starting Emacs as daemon, this is executed but has no effect. Afterwards, running anemacsclient -c .
opens an X frame, with fonts at their defaults.What do I need to hook so that
(unicode-fonts-setup)
is run for X frames created foremacsclient
?The text was updated successfully, but these errors were encountered: