Default all eshell hooks to nil (bug#5375)

* eshell/esh-mode.el (eshell-kill-buffer-function): New function.
(eshell-mode): Use eshell-kill-buffer-function.
Run the -initialize functions independently of the -load-hooks.
* eshell/esh-proc.el (eshell-kill-process-function): New function.
(eshell-gather-process-output, eshell-sentinel)
(eshell-interrupt-process, eshell-kill-process, eshell-quit-process):
Use eshell-kill-process-function.
* eshell/em-alias.el (eshell-alias-load-hook):
* eshell/em-banner.el (eshell-banner-load-hook):
* eshell/em-cmpl.el (eshell-cmpl-load-hook):
* eshell/em-dirs.el (eshell-dirs-load-hook):
* eshell/em-glob.el (eshell-glob-load-hook):
* eshell/em-hist.el (eshell-hist-load-hook):
* eshell/em-pred.el (eshell-pred-load-hook):
* eshell/em-prompt.el (eshell-prompt-load-hook):
* eshell/em-rebind.el (eshell-rebind-load-hook):
* eshell/em-script.el (eshell-script-load-hook):
* eshell/em-smart.el (eshell-smart-load-hook):
* eshell/em-term.el (eshell-term-load-hook):
* eshell/em-unix.el (eshell-unix-load-hook):
* eshell/esh-arg.el (eshell-arg-load-hook):
* eshell/esh-cmd.el (eshell-cmd-load-hook):
* eshell/esh-ext.el (eshell-ext-load-hook):
* eshell/esh-io.el (eshell-io-load-hook):
* eshell/esh-mode.el (eshell-exit-hook):
* eshell/esh-proc.el (eshell-proc-load-hook, eshell-kill-hook):
* eshell/esh-var.el (eshell-var-load-hook):
Set default hook values to nil.  (Bug#5375)
This commit is contained in:
Glenn Morris 2011-03-04 20:11:05 -08:00
parent 4a0f18a899
commit d783d30393
21 changed files with 107 additions and 45 deletions

View file

@ -89,9 +89,10 @@ That is to say, the first time during an Emacs session."
:type 'hook
:group 'eshell-mode)
(defcustom eshell-exit-hook '(eshell-query-kill-processes)
(defcustom eshell-exit-hook nil
"A hook that is run whenever `eshell' is exited.
This hook is only run if exiting actually kills the buffer."
:version "24.1" ; removed eshell-query-kill-processes
:type 'hook
:group 'eshell-mode)
@ -287,6 +288,17 @@ This is used by `eshell-watch-for-password-prompt'."
;;; User Functions:
(defun eshell-kill-buffer-function ()
"Function added to `kill-buffer-hook' in Eshell buffers.
This runs the function `eshell-kill-processes-on-exit',
and the hook `eshell-exit-hook'."
;; It's fine to run this unconditionally since it can be customized
;; via the `eshell-kill-processes-on-exit' variable.
(and (fboundp 'eshell-query-kill-processes)
(not (memq 'eshell-query-kill-processes eshell-exit-hook))
(eshell-query-kill-processes))
(run-hooks 'eshell-exit-hook))
;;;###autoload
(defun eshell-mode ()
"Emacs shell interactive mode.
@ -403,17 +415,15 @@ This is used by `eshell-watch-for-password-prompt'."
(unless (file-exists-p eshell-directory-name)
(eshell-make-private-directory eshell-directory-name t))
;; load core Eshell modules for this session
(dolist (module (eshell-subgroups 'eshell))
(run-hooks (intern-soft (concat (symbol-name module)
"-load-hook"))))
;; load extension modules for this session
(dolist (module eshell-modules-list)
(let ((load-hook (intern-soft (concat (symbol-name module)
"-load-hook"))))
(if (and load-hook (boundp load-hook))
(run-hooks load-hook))))
;; Load core Eshell modules, then extension modules, for this session.
(dolist (module (append (eshell-subgroups 'eshell) eshell-modules-list))
(let ((load-hook (intern-soft (format "%s-load-hook" module)))
(initfunc (intern-soft (format "%s-initialize" module))))
(when (and load-hook (boundp load-hook))
(if (memq initfunc (symbol-value load-hook)) (setq initfunc nil))
(run-hooks load-hook))
;; So we don't need the -initialize functions on the hooks (b#5375).
(and initfunc (fboundp initfunc) (funcall initfunc))))
(if eshell-send-direct-to-subprocesses
(add-hook 'pre-command-hook 'eshell-intercept-commands t t))
@ -428,10 +438,7 @@ This is used by `eshell-watch-for-password-prompt'."
(add-hook 'eshell-pre-command-hook 'eshell-command-started nil t)
(add-hook 'eshell-post-command-hook 'eshell-command-finished nil t))
(add-hook 'kill-buffer-hook
(function
(lambda ()
(run-hooks 'eshell-exit-hook))) t t)
(add-hook 'kill-buffer-hook 'eshell-kill-buffer-function t t)
(if eshell-first-time-p
(run-hooks 'eshell-first-time-mode-hook))