Backport 2010-04-10T10:52:30Z!mituharu@math.s.chiba-u.ac.jp from trunk
[emacs.git] / lisp / eshell / esh-module.el
blobcf66f62648539b2a6a9fa206f6b013bd3363b528
1 ;;; esh-module.el --- Eshell modules
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: John Wiegley <johnw@gnu.org>
7 ;; Keywords: processes
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Code:
26 (provide 'esh-module)
28 (require 'eshell)
29 (require 'esh-util)
31 (defgroup eshell-module nil
32 "The `eshell-module' group is for Eshell extension modules, which
33 provide optional behavior which the user can enable or disable by
34 customizing the variable `eshell-modules-list'."
35 :tag "Extension modules"
36 :group 'eshell)
38 ;; load the defgroup's for the standard extension modules, so that
39 ;; documentation can be provided when the user customize's
40 ;; `eshell-modules-list'.
41 (load "esh-groups" nil 'nomessage)
43 ;;; User Variables:
45 (defcustom eshell-module-unload-hook
46 '(eshell-unload-extension-modules)
47 "*A hook run when `eshell-module' is unloaded."
48 :type 'hook
49 :group 'eshell-module)
51 (defcustom eshell-modules-list
52 '(eshell-alias
53 eshell-banner
54 eshell-basic
55 eshell-cmpl
56 eshell-dirs
57 eshell-glob
58 eshell-hist
59 eshell-ls
60 eshell-pred
61 eshell-prompt
62 eshell-script
63 eshell-term
64 eshell-unix)
65 "*A list of optional add-on modules to be loaded by Eshell.
66 Changes will only take effect in future Eshell buffers."
67 :type (append
68 (list 'set ':tag "Supported modules")
69 (mapcar
70 (function
71 (lambda (modname)
72 (let ((modsym (intern modname)))
73 (list 'const
74 ':tag (format "%s -- %s" modname
75 (get modsym 'custom-tag))
76 ':link (caar (get modsym 'custom-links))
77 ':doc (concat "\n" (get modsym 'group-documentation)
78 "\n ")
79 modsym))))
80 (sort (mapcar 'symbol-name
81 (eshell-subgroups 'eshell-module))
82 'string-lessp))
83 '((repeat :inline t :tag "Other modules" symbol)))
84 :group 'eshell-module)
86 ;;; Code:
88 (defsubst eshell-using-module (module)
89 "Return non-nil if a certain Eshell MODULE is in use.
90 The MODULE should be a symbol corresponding to that module's
91 customization group. Example: `eshell-cmpl' for that module."
92 (memq module eshell-modules-list))
94 (defun eshell-unload-extension-modules ()
95 "Unload any memory resident extension modules."
96 (eshell-for module (eshell-subgroups 'eshell-module)
97 (if (featurep module)
98 (ignore-errors
99 (message "Unloading %s..." (symbol-name module))
100 (unload-feature module)
101 (message "Unloading %s...done" (symbol-name module))))))
103 ;; arch-tag: 97a3fa16-9d08-40e6-bc2c-36bd70986507
104 ;;; esh-module.el ends here