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)))
(progn
(select-frame frame)
(when (or gui ter)
(progn
;; setup the smart-mode-line and its theme
(setq sml/no-confirm-load-theme t)
(sml/setup)
(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)
(progn
(setq sml/no-confirm-load-theme t)
(sml/setup)
(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?