Advanced Emacs customizations
Evaluation order
If you write your own Emacs code, be careful that functions and variables take the value of their last loaded version. The order in which Emacs code is evaluated thus matters.
You want to evaluate as little as possible when you launch Emacs to speed up start-up time (lazy evaluation): you don’t want to load every single package that you have installed.
This means that if you overwrite a function or variable of a mode in your init file, the init file is read at start-up, but when that mode is launched, the default function/variable will overwrite the custom one you wrote in your init file.
To by-pass this problem, you can use eval-after-load
.
Example:
(eval-after-load"markdown"
defun markdown-demote ()
'( ...))
use-package has the :init
and :config
keyword symbols that ensure that the following expressions are evaluated respectively before or after the loading of a package.
Customizing kbd
Like everything else, kbds can be customized.
Global kbd
Most modes come with specific keymaps: sets of kbd only active when the mode is enabled.
For example, to modify the kbd for the function markdown-outline-previous
in the markdown-mode-map
:
"M-p") 'markdown-outline-previous) (define-key markdown-mode-map (kbd
Or, using use-package:
use-package markdown-mode
(
:bind (:map markdown-mode-map"M-p" . markdown-outline-previous))) (