all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Understanding after-make-frame-functions
@ 2016-05-16 23:35 Kaushal Modi
  2016-05-16 23:42 ` Kaushal Modi
  2016-05-17  3:44 ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: Kaushal Modi @ 2016-05-16 23:35 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi all,

I have certain code in my config like the find-font function call, which I
need to have in a after-make-frame-functions hook if I want that to work
correctly in an emacsclient session. So I have it so, and it works fine.

But I just learnt that that hook is apparently not called when I launch
emacs in a non-daemon mode (plain old emacs&).

Here is a little snippet for testing

===== temp.el =====
(add-hook 'after-make-frame-functions (lambda (frame) (message "frame:
%S")))
=====

When you run "emacs -Q -l temp.el&", the above message will not be printed.
But it prints fine when emacs is launched in daemon mode.

So I need to add the find-font call in window-setup-hook (which non-daemon
emacs can see but emacsclient cannot. Is that right?).

So I have ended up with few code snippets in both
after-make-frame-functions and in window-setup-hook.  I have the actual
snippets from my config at the end of this email, in the case they come
helpful in understanding my problem statement.

(1) Is the above after-make-frame-functions behavior specific to daemon
sessions as expected? If so, I was unable to find reference to that in the
emacs/elisp manual.
(2) Is window-setup-hook supposed to run only in non-daemon emacs?
(3) What would be a more concise manner to do stuff like linum activation,
find-font call, etc. correctly in both emacs and emacsclient?

Thanks.

--
Kaushal

##########
===== (in init.el) =====
;;
https://github.com/kaushalmodi/.emacs.d/blob/fa33440cc16c0601ad55d94a762a03f4f7f66a50/init.el#L324-L332
(defun modi/symbola-font-check (&optional frame)
  ;; The below `select-frame' form is required for the `find-font'
  ;; to work correctly when using emacs daemon (emacsclient).
  (when frame
    (select-frame frame))
  (require 'setup-symbola))
(if (daemonp) ; only for emacsclient launches
    (add-hook 'after-make-frame-functions #'modi/symbola-font-check)
  (add-hook 'window-setup-hook #'modi/symbola-font-check))
=====

===== setup-symbola.el =====
;;
https://github.com/kaushalmodi/.emacs.d/blob/fa33440cc16c0601ad55d94a762a03f4f7f66a50/setup-files/setup-symbola.el
(defvar font-symbola-p nil
  "If non-nil, Symbola font is available on the system.")
;; Set `font-symbola-p' to t if Symbola font is available.
(when (find-font (font-spec :name "Symbola"))
  ;; Manually choose a fallback font for Unicode
  ;;
http://endlessparentheses.com/manually-choose-a-fallback-font-for-unicode.html
  (set-fontset-font "fontset-default" nil (font-spec :size 20 :name
"Symbola"))
  (setq font-symbola-p t))
(provide 'setup-symbola)
=====
I do the above so that code snippets using unicode available only in
Symbola font can be nested in a "(with-eval-after-load 'setup-symbola (when
font-symbola-p ..))" form.

===== (in setup-linum.el) =====
;;
https://github.com/kaushalmodi/.emacs.d/blob/fa33440cc16c0601ad55d94a762a03f4f7f66a50/setup-files/setup-linum.el#L169-L171
(if (daemonp) ; only for emacsclient launches
    (add-hook 'after-make-frame-functions #'my-fn-to-enable-linum)
  (add-hook 'window-setup-hook #'my-fn-to-enable-linum))
=====
I get linum font error when running emacsclient if I do not put linum
enabling in after-make-frame-functions hook.
-- 

-- 
Kaushal Modi


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-05-18  2:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-16 23:35 Understanding after-make-frame-functions Kaushal Modi
2016-05-16 23:42 ` Kaushal Modi
2016-05-17  3:39   ` Eli Zaretskii
2016-05-17  3:44 ` Eli Zaretskii
2016-05-17 16:15   ` Kaushal Modi
2016-05-17 16:36     ` Eli Zaretskii
2016-05-17 18:08       ` Kaushal Modi
2016-05-17 20:18         ` Eli Zaretskii
2016-05-18  2:31           ` Kaushal Modi
2016-05-18  2:39             ` Eli Zaretskii
2016-05-18  2:46               ` Kaushal Modi

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.