I picked up this code from:

Is there any way to run a hook function only once?

(setq myGraphicModeHash (make-hash-table :test 'equal :size 2))
(puthash "gui" t myGraphicModeHash)
(puthash "term" t myGraphicModeHash)
(defun emacsclient-setup-theme-function (frame)
  (let ((gui (gethash "gui" myGraphicModeHash))
        (ter (gethash "term" myGraphicModeHash)))
      (select-frame frame)
      (when (or gui ter) 
          ;; setup the smart-mode-line and its theme
          (setq sml/no-confirm-load-theme t)
          (sml/apply-theme 'dark)
          (load-theme 'material t)
          (if (display-graphic-p)
              (puthash "gui" nil myGraphicModeHash)
            (puthash "term" nil myGraphicModeHash))))
      (when (not (and gui ter))
        (remove-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)))))
(if (daemonp)
    (add-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)
    (setq sml/no-confirm-load-theme t)
    (load-theme 'material t)

starting the first frame runs fine, the second frame causes the flash effect and the rest of new frames have no problem. It is just the second starting frame that still has this issue. OP in the above link says that the code fixed it for him, What is my code missing?

  • You may want to report a bug to the emacs mailing list. – eflanigan00 Jul 3 '17 at 12:30
  • To file a bug report: M-x report-emacs-bug. – Drew May 6 '18 at 0:27

Your Answer

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

Browse other questions tagged or ask your own question.