¿Hay alguna diferencia entre configurar cosas para un modo usando eval-after-load
y usando el hook de modo?eval-after-load vs. mode hook
He visto un código donde define-key
se usa dentro de un gancho de modo principal, y algún otro código donde define-key
se usa en el formulario eval-after-load
.
Actualización:
Para una mejor comprensión, aquí es un ejemplo del uso de eval-post-carga y modo de ganchos con org-mode. El código puede ejecutar antes de(load "org")
o (require 'org)
o (package-initialize)
.
;; The following two lines of code set some org-mode options.
;; Usually, these can be outside (eval-after-load ...) and work.
;; In cases that doesn't work, try using setq-default or set-variable
;; and putting them in (eval-after-load ...), if the
;; doc for the variables don't say what to do.
;; Or use Customize interface.
(setq org-hide-leading-stars t)
(setq org-return-follows-link t)
;; "org" because C-h f org-mode RET says that org-mode is defined in org.el
(eval-after-load "org"
'(progn
;; Establishing your own keybindings for org-mode.
;; Variable org-mode-map is available only after org.el or org.elc is loaded.
(define-key org-mode-map (kbd "<C-M-return>") 'org-insert-heading-respect-content)
(define-key org-mode-map (kbd "<M-right>") nil) ; erasing a keybinding.
(define-key org-mode-map (kbd "<M-left>") nil) ; erasing a keybinding.
(defun my-org-mode-hook()
;; The following two lines of code is run from the mode hook.
;; These are for buffer-specific things.
;; In this setup, you want to enable flyspell-mode
;; and run org-reveal for every org buffer.
(flyspell-mode 1)
(org-reveal))
(add-hook 'org-mode-hook 'my-org-mode-hook)))
+1 para * "org" porque C-h f org-mode RET dice que org-mode se define en org.el *. Estaba luchando para obtener 'eval-after-load' para evaluar' 'nxml-mode', ¡y este consejo funcionó! –