redguardtoo / emacs.d

Fast and robust Emacs setup.
http://blog.binchen.org
GNU General Public License v3.0
2.41k stars 616 forks source link

`require-init` in `~/.custom.el` not working #1020

Closed fenguoerbian closed 1 year ago

fenguoerbian commented 1 year ago

I use auctex for writing latex in emacs. Currently I'm using (require-init 'init-auctex) to load my auctex settings (init-auctex.el is located at ~/.emacs.d/lisp/.

This works fine until recently I ran a git pull --rabase to update the config. Now the setings of auctex does not work. I try to rebase onto different commits and find that it's d282b415e9d678eb561f123ed0ef236efd1b58dd, the change from

(load (expand-file-name "~/.custom.el") t nil)))

to

(my-run-with-idle-timer 1 (lambda () (load "~/.custom.el" t nil)))))

that seems to make the require-init not take effect. It baffles me bacause (load-theme 'one-dark t) in my .custom.el totally works, but that require-init not.

I'm not an expert in emacs and I'm asking for your advise about how to make my customization work again. Thanks a lot.

redguardtoo commented 1 year ago

Can't reproduce issue,

Here is my ~/.emacs.d/lisp/init-hello.el,

(message "hello world")
(provide 'init-hello)
fenguoerbian commented 1 year ago

Thanks for the reply. According to your suggestion I find that require-init did work. It's some add-hook in my configuration that does not work.

My ~/.emacs.d/lisp/init-auctex.el

(message "before add-hook turn-on-reftex")
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(provide 'init-auctex)

and my ~/.custom.el

(require-init 'init-auctex)

After opening a .tex file, the message buffer shows the before add-hook turn-on-reftex, but M-x describe-mode RET does not show Reftex minor mode.

redguardtoo commented 1 year ago

Maybe for some reason, reftex-mode is not loaded yet, you can always use require to manually load it anyway.

fenguoerbian commented 1 year ago

Will do. Thanks a lot.

BlacAmDK commented 1 year ago

Maybe for some reason, reftex-mode is not loaded yet, you can always use require to manually load it anyway.

Because after the change from (load (expand-file-name "~/.custom.el") t nil))) to (my-run-with-idle-timer 1 (lambda () (load "~/.custom.el" t nil)))))

The code in the add-hook in custom.el will be executed after the loading of the LaTex mode.

My Reproduction steps:

  1. Add (add-hook 'css-mode-hook (lambda () (message "css-hook is running"))) to custom.el
  2. Run emacs -nw xxx.css, the hook will not be executed.