that help you to customize it in various ways. Calc uses the Lisp
function @code{run-hooks} to invoke the hooks shown below. Several
other customization-related variables are also described here.
-
-@defvar calc-load-hook
-This hook is called at the end of @file{calc.el}, after the file has
-been loaded, before any functions in it have been called, but after
-@code{calc-mode-map} and similar variables have been set up.
-@end defvar
-
-@defvar calc-ext-load-hook
-This hook is called at the end of @file{calc-ext.el}.
-@end defvar
+To run code after Calc has loaded, use @code{with-eval-after-load}.
@defvar calc-start-hook
This hook is called as the last step in a @kbd{M-x calc} command.
@file{default.el} in the @file{site-lisp} directory, put
@example
-(add-hook 'dired-load-hook
- (lambda ()
- (load "dired-x")
- ;; Set dired-x global variables here. For example:
- ;; (setq dired-guess-shell-gnutar "gtar")
- ;; (setq dired-x-hands-off-my-keys nil)
- ))
+(with-eval-after-load 'dired
+ (require 'dired-x)
+ ;; Set dired-x global variables here. For example:
+ ;; (setq dired-guess-shell-gnutar "gtar")
+ ;; (setq dired-x-hands-off-my-keys nil)
+ ))
(add-hook 'dired-mode-hook
(lambda ()
;; Set dired-x buffer-local variables here. For example:
or call @code{dired-x-bind-find-file} after changing the value.
@example
-(add-hook 'dired-load-hook
- (lambda ()
- ;; Bind dired-x-find-file.
- (setq dired-x-hands-off-my-keys nil)
- (load "dired-x")
- ))
+(with-eval-after-load 'dired
+ ;; Bind dired-x-find-file.
+ (setq dired-x-hands-off-my-keys nil)
+ (require 'dired-x))
@end example
@node Omitting Files in Dired
@end table
@noindent
-In order to make Dired Omit work you first need to load @file{dired-x.el}
-inside @code{dired-load-hook} (@pxref{Installation}) and then evaluate
+In order to make Dired Omit work you need to load @file{dired-x}
+after loading @file{dired} (@pxref{Installation}) and then evaluate
@code{(dired-omit-mode 1)} in some way (@pxref{Omitting Variables}).
@ifnottex
@item
@cindex RCS files, how to omit them in Dired
@cindex omitting RCS files in Dired
-If you wish to avoid seeing RCS files and the @file{RCS} directory, then put
+If you wish to avoid seeing RCS files and the @file{RCS} directory, then use
@example
(setq dired-omit-files
@end example
@noindent
-in the @code{dired-load-hook} (@pxref{Installation}). This assumes
+after loading @file{dired-x} (@pxref{Installation}). This assumes
@code{dired-omit-localp} has its default value of @code{no-dir} to make the
@code{^}-anchored matches work. As a slower alternative, with
@code{dired-omit-localp} set to @code{nil}, you can use @code{/} instead of
@cindex omitting tib files in Dired
If you use @code{tib}, the bibliography program for use with @TeX{} and
@LaTeX{}, and you
-want to omit the @file{INDEX} and the @file{*-t.tex} files, then put
+want to omit the @file{INDEX} and the @file{*-t.tex} files, then use
@example
(setq dired-omit-files
@end example
@noindent
-in the @code{dired-load-hook} (@pxref{Installation}).
+after loading @file{dired-x} (@pxref{Installation}).
@item
@cindex dot files, how to omit them in Dired
@cindex omitting dot files in Dired
If you do not wish to see @samp{dot} files (files starting with a @file{.}),
-then put
+then use
@example
(setq dired-omit-files
@end example
@noindent
-in the @code{dired-load-hook} (@pxref{Installation}). (Of course, a
+after loading @file{dired-x} (@pxref{Installation}). (Of course, a
better way to achieve this particular goal is simply to omit @samp{-a} from
@code{dired-listing-switches}.)
(normally bound to @kbd{C-x 4 C-f}).
In order to use this feature, you will need to set
-@code{dired-x-hands-off-my-keys} to @code{nil} inside @code{dired-load-hook}
+@code{dired-x-hands-off-my-keys} to @code{nil} before loading @file{dired-x}
(@pxref{Optional Installation File At Point}).
@table @code
The bulk of customization can be done via the following hooks:
@table @code
-@item ediff-load-hook
-@vindex ediff-load-hook
-This hook can be used to change defaults after Ediff is loaded.
-
@item ediff-before-setup-hook
@vindex ediff-before-setup-hook
Hook that is run just before Ediff rearranges windows to its liking.
@vindex ediff-mode-map
This hook can be used to alter bindings in Ediff's keymap,
@code{ediff-mode-map}. These hooks are
-run right after the default bindings are set but before
-@code{ediff-load-hook}. The regular user needs not be concerned with this
+run right after the default bindings are set.
+The regular user needs not be concerned with this
hook---it is provided for implementers of other Emacs packages built on top
of Ediff.
difference.
Users can supply their own functions to specify how Ediff should do
-selective browsing. To change the default Ediff function, add a function to
-@code{ediff-load-hook} which will do the following assignments:
+selective browsing. To change the default Ediff function, use
+something like the following:
@example
-(setq ediff-hide-regexp-matches-function 'your-hide-function)
-(setq ediff-focus-on-regexp-matches-function 'your-focus-function)
+(with-eval-after-load 'ediff
+ (setq ediff-hide-regexp-matches-function 'your-hide-function)
+ (setq ediff-focus-on-regexp-matches-function 'your-focus-function))
@end example
@strong{Useful hint}: To specify a regexp that matches everything, don't
If you are unhappy with just @emph{some} of the aspects of the default
faces, you can modify them when Ediff is being loaded using
-@code{ediff-load-hook}. For instance:
+@code{with-eval-after-load}. For instance:
@smallexample
-(add-hook 'ediff-load-hook
- (lambda ()
- (set-face-foreground
- ediff-current-diff-face-B "blue")
- (set-face-background
- ediff-current-diff-face-B "red")
- (make-face-italic
- ediff-current-diff-face-B)))
+(with-eval-after-load 'ediff
+ (set-face-foreground
+ ediff-current-diff-face-B "blue")
+ (set-face-background
+ ediff-current-diff-face-B "red")
+ (make-face-italic ediff-current-diff-face-B))
@end smallexample
-@strong{Please note:} to set Ediff's faces, use only @code{copy-face}
-or @code{set/make-face-@dots{}} as shown above. Emacs's low-level
-face-manipulation functions should be avoided.
-
@node Narrowing
@section Narrowing
load @code{dired-x} by adding the following to your @file{.emacs} file:
@lisp
-(add-hook 'dired-load-hook
- (lambda ()
- (require 'dired-x)))
+(with-eval-after-load 'dired
+ (require 'dired-x))
@end lisp
With @code{dired-x} loaded, @kbd{M-o} toggles omitting in each dired buffer.
@table @code
-@item gnus-load-hook
-@vindex gnus-load-hook
-A hook run while Gnus is being loaded. Note that this hook will
-normally be run just once in each Emacs session, no matter how many
-times you start Gnus.
-
@item gnus-before-startup-hook
@vindex gnus-before-startup-hook
A hook called as the first thing when Gnus is started.
simply add the following to your @file{.emacs}:
@lisp
- (add-hook 'idlwave-load-hook
- (lambda () (require 'idlw-complete-structtag)))
+(with-eval-after-load 'idlwave
+ (require 'idlw-complete-structtag))
@end lisp
Once enabled, you'll also be able to access online help on the structure
Normal hook. Executed when a buffer is put into @code{idlwave-mode}.
@end defopt
-@defopt idlwave-load-hook
-Normal hook. Executed when @file{idlwave.el} is loaded.
-@end defopt
-
@node The IDLWAVE Shell
@chapter The IDLWAVE Shell
@cindex IDLWAVE shell
this also to @kbd{M-n} and @kbd{M-p}.
@lisp
-(add-hook 'org-load-hook
- (lambda ()
- (define-key org-mode-map "\M-n" 'org-next-link)
- (define-key org-mode-map "\M-p" 'org-previous-link)))
+(with-eval-after-load 'org
+ (define-key org-mode-map "\M-n" 'org-next-link)
+ (define-key org-mode-map "\M-p" 'org-previous-link))
@end lisp
@end table
Note that this variable has to be set before @RefTeX{} is loaded to
have an effect.
-@vindex reftex-load-hook
-Changing and adding to @RefTeX{}'s key bindings is best done in the hook
-@code{reftex-load-hook}. For information on the keymaps
+Changing and adding to @RefTeX{}'s key bindings is best done using
+@code{with-eval-after-load}. For information on the keymaps
which should be used to add keys, see @ref{Keymaps and Hooks}.
@node Faces
The keymap for @RefTeX{} mode.
@end deffn
-@deffn {Normal Hook} reftex-load-hook
-Normal hook which is being run when loading @file{reftex.el}.
-@end deffn
-
@deffn {Normal Hook} reftex-mode-hook
Normal hook which is being run when turning on @RefTeX{} mode.
@end deffn
line to your init file:
@example
-(add-hook 'speedbar-load-hook (lambda () (require 'semantic/sb)))
+(with-eval-after-load 'speedbar (require 'semantic/sb))
@end example
@noindent
@cindex @code{speedbar-visiting-tag-hook}
@item speedbar-visiting-tag-hook
Hooks run when speedbar visits a tag in the selected frame.
-@cindex @code{speedbar-load-hook}
-@item speedbar-load-hook
-Hooks run when speedbar is loaded.
@cindex @code{speedbar-reconfigure-keymaps-hook}
@item speedbar-reconfigure-keymaps-hook
Hooks run when the keymaps are regenerated. Keymaps are reconfigured
This function creates a special keymap for use in speedbar.
@item
-Call your install function, or assign it to a hook like this:
+Call your install function, like this:
@smallexample
-(if (featurep 'speedbar)
- (@var{name}-install-speedbar-variables)
- (add-hook 'speedbar-load-hook '@var{name}-install-speedbar-variables))
+(with-eval-after-load 'speedbar
+ (@var{name}-install-speedbar-variables))
@end smallexample
@item
@item viper-always t
@code{t} means: leave it to Viper to decide when a buffer must be brought
up in Vi state,
-Insert state, or Emacs state. This heuristics works well in virtually all
-cases. @code{nil} means you either has to invoke @code{viper-mode} manually
+Insert state, or Emacs state. This heuristic works well in virtually all
+cases. @code{nil} means you either have to invoke @code{viper-mode} manually
for each buffer (or you can add @code{viper-mode} to the appropriate major mode
-hooks using @code{viper-load-hook}).
+hooks using @code{with-eval-after-load}).
This option must be set in your Viper customization file.
@item viper-custom-file-name "~/.emacs.d/viper"
@item viper-emacs-state-hook nil
List of (parameterless) functions called just after switching from Vi state
to Emacs state.
-@item viper-load-hook nil
-List of (parameterless) functions called just after loading Viper. This is
-the last chance to do customization before Viper is up and running.
@end table
@noindent
You can reset some of these constants in Viper with the Ex command @kbd{:set}