Alessandro Bertulli writes: > Stefan Monnier via Users list for the GNU Emacs text editor writes: > >> `LaTeX-mode-map`, like most package variables, is only defined once >> its package is actually loaded, which is done lazily in response to the >> use of the package (e.g. opening a LaTeX file). >> >> So it's normal that `LaTeX-mode-map` is not defined when your init file >> is loaded. This is on purpose to try and speed up Emacs's startup. >> >> You can use things like: >> >> (with-eval-after-load 'latex >> (define-key LaTeX-mode-map (kbd "C-c a") #'my-bar) >> (define-key LaTeX-mode-map (kbd "C-c b") #'my-foo)) > > You honestly opened a world to me. I have long wondered the difference > between require and with-eval-after-load (of course I could have read > the docs, but I never found time). :-) > >> or >> >> (defun my-latex-setup () >> (define-key LaTeX-mode-map (kbd "C-c a") #'my-bar) >> (define-key LaTeX-mode-map (kbd "C-c b") #'my-foo)) >> (add-hook 'LaTeX-mode-hook #'my-latex-setup) >> >> in order to delay the customization to after the variable is defined. > > Isn't this redundant? You call the function every time a LaTeX file is > loaded. The first method is preferrable, right? Yeah, the first one is IMHO better. > > Alessandro > -- Akib Azmain Turja Find me on Mastodon at @akib@hostux.social. This message is signed by me with my GnuPG key. Its fingerprint is: 7001 8CE5 819F 17A3 BBA6 66AF E74F 0EFA 922A E7F5