short story: The theme just did not show up automatically at emacs start, when it is invoked by an after-init-hook. However, with emacs-startup-hook it worked as expected:
(use-package heaven-and-hell ... ;;:hook (after-init . heaven-and-hell-init-hook) ;; does not work :hook (emacs-startup . heaven-and-hell-init-hook) ;; this one does I run plain emacs (emacs -l test.el -Q) with a test script (modified from this question)
test.el
(defun buffer-hook-function () (append-to-file (format "%s" (buffer-list)) nil "log.txt") (append-to-file "\n" nil "log.txt") ) (append-to-file "Running ...\n" nil "log.txt") (add-hook 'emacs-startup-hook (lambda () (append-to-file "emacs-startup-hook\n" nil "log.txt"))) (add-hook 'after-init-hook (lambda () (append-to-file "after-init-hook\n" nil "log.txt"))) (add-hook 'before-init-hook (lambda () (append-to-file "before-init-hook\n" nil "log.txt"))) (add-hook 'window-setup-hook (lambda () (append-to-file "window-setup-hook\n" nil "log.txt"))) (add-hook 'emacs-startup-hook (lambda () (append-to-file "emacs-startup-hook after window-setup-hook\n" nil "log.txt"))) (add-hook 'emacs-startup-hook (lambda () (append-to-file (format "after-init-time %.2fs (printed via emacs-startup-hook)\n" (float-time (time-subtract (current-time) after-init-time))) nil "log.txt"))) (add-hook 'buffer-list-update-hook 'buffer-hook-function) log.txt
Running ... (*scratch* *Minibuf-0* *Messages* *code-conversion-work* *Echo Area 0* *Echo Area 1*) after-init-time 0.03s (printed via emacs-startup-hook) emacs-startup-hook after window-setup-hook emacs-startup-hook window-setup-hook (*scratch* *Minibuf-0* *Messages* *code-conversion-work* *Echo Area 0* *Echo Area 1*) So after-init-hook does not appear, but after-init-time seems to be set, which seems to come from an after-init-hook.
I still do not see why after-init-hook is not called. This question refers to the command-line processing part of after-init-hook, so I tried different configurations, terminals and (non-)window modes.
- Why after-init-hook is not called?
- Does this mean, other packages with init hooks can also fail?
Edit: Using emacs 26.2, Manjaro Linux 18.0.4 xfce
Update: after rewriting my theme and addressing an issue in spacemacs-theme, after-init seems to work so far via heaven-and-hell. emacs-startup hook had other issues like additional syntax highlighting via prog-mode-hook did not work.
Update 2: The example test.el perhaps always fails. If you run without -Q it is invoked: emacs -l test.el:
Running ... <snip> after-init-hook (*scratch* *Minibuf-0* *Messages* *code-conversion-work* *Echo Area 0* *Echo Area 1* *load*) Running ... (*scratch* *Minibuf-0* *Messages* *code-conversion-work* *Echo Area 0* *Echo Area 1*) after-init-time 0.06s (printed via emacs-startup-hook) emacs-startup-hook after window-setup-hook emacs-startup-hook window-setup-hook <snip>