From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.help Subject: Understanding after-make-frame-functions Date: Mon, 16 May 2016 23:35:15 +0000 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1463441753 10711 80.91.229.3 (16 May 2016 23:35:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 May 2016 23:35:53 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 17 01:35:48 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b2S39-0003xx-P8 for geh-help-gnu-emacs@m.gmane.org; Tue, 17 May 2016 01:35:47 +0200 Original-Received: from localhost ([::1]:47787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2S39-0005Tc-5Q for geh-help-gnu-emacs@m.gmane.org; Mon, 16 May 2016 19:35:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2S2q-0005PC-2A for help-gnu-emacs@gnu.org; Mon, 16 May 2016 19:35:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2S2n-0006Qo-B3 for help-gnu-emacs@gnu.org; Mon, 16 May 2016 19:35:26 -0400 Original-Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:35248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2S2n-0006Qk-4O for help-gnu-emacs@gnu.org; Mon, 16 May 2016 19:35:25 -0400 Original-Received: by mail-oi0-x22d.google.com with SMTP id x19so292667143oix.2 for ; Mon, 16 May 2016 16:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=v7P5WPL90Q4H0rEnvJEoHMzdLULd8l2vt+8RmidBh+0=; b=EJnntNYApz1fylwCyMR9XejuD6AhRyttAHOvmANsloMrHUM7Hy0TTZPtrhqIyACCKU WTacijqxhmxwKjU4RrJisaLPyRExoppQiOd71NJ8hZ3h4CCLTNapdn6b6XGWPjO+18Mk ysKptgB3dthEukI0UQeY18GQ2vUHYY/Bv3bLIU7X0MaDPfXaG/FVTm/fk8z4jV5oPL01 IhXiHve49Uxvutf4uk7OFBZkM5k0uZHpRQB4pCwPmBefRXzdaJIezAjL6yyzR6s5ipcC nHVRkUJ+a9GvTVasT3K1/CUbH6lPqSs5YEP6jAN3xrUzGBhs4RdONArEmoHyi9l9FoVL yVGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=v7P5WPL90Q4H0rEnvJEoHMzdLULd8l2vt+8RmidBh+0=; b=m4Q2fi7eci3ynm4e2i6z9QQAH6jdfAE20f+mEv/XP3HT1O73kcS6JuB0Qb53TG4Wru xObev4Ka1QOCFLtTPIkuMAg9wS4OyVzIdstrh/l/12MjUaH5FAcHw4HU1Q1MlI2wgljT tJKLxND75IpDqhVYVr+oQXhu+OjKlhZhsiE389P8QJIfotJI4irBxzTmSpJ0m0RNPVsi JCquz7nGIJZtBxKlJlqEPR5CDr0DqVjqZsEf66lw1PZy+scZMYsiay8ZezwmuizMt6A1 606HgOG5qAsrgS86fMZ+EfYWpp6htTm7lrlbsd9qbJLBfQHs9qvQjUvy5YVCyyey25pf 2YmA== X-Gm-Message-State: AOPr4FUcbAdjmWlq4gVUE0dfS+xIjsnjc72XhI9mc7Ke7e+CdCggowTuibZs1XhyVpl3Z6dBksm/qR+7e0urYg== X-Received: by 10.157.45.136 with SMTP id g8mr19704676otb.133.1463441724582; Mon, 16 May 2016 16:35:24 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::22d X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110003 Archived-At: 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