Variable: eshell-named-command-hook

eshell-named-command-hook is a customizable variable defined in esh-cmd.el.gz.

Value

nil

Documentation

A set of functions called before a named command is invoked.

Each function will be passed the command name and arguments that were passed to eshell-named-command.

If any of the functions returns a non-nil value, the named command will not be invoked, and that value will be returned from eshell-named-command.

In order to substitute an alternate command form for execution, the hook function should throw it using the tag eshell-replace-command. For example:

  (add-hook 'eshell-named-command-hook #'subst-with-cd)
  (defun subst-with-cd (command args)
    (throw 'eshell-replace-command
(eshell-parse-command "cd" args)))

Although useless, the above code will cause any non-glob, non-Lisp command (i.e., ls as opposed to *ls or (ls)) to be replaced by a call to cd using the arguments that were passed to the function.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defcustom eshell-named-command-hook nil
  "A set of functions called before a named command is invoked.
Each function will be passed the command name and arguments that were
passed to `eshell-named-command'.

If any of the functions returns a non-nil value, the named command
will not be invoked, and that value will be returned from
`eshell-named-command'.

In order to substitute an alternate command form for execution, the
hook function should throw it using the tag `eshell-replace-command'.
For example:

  (add-hook \\='eshell-named-command-hook #\\='subst-with-cd)
  (defun subst-with-cd (command args)
    (throw \\='eshell-replace-command
	   (eshell-parse-command \"cd\" args)))

Although useless, the above code will cause any non-glob, non-Lisp
command (i.e., `ls' as opposed to `*ls' or `(ls)') to be replaced by a
call to `cd' using the arguments that were passed to the function."
  :type 'hook)