Commit | Line | Data |
---|---|---|
ae5e4c48 | 1 | ;;; esh-module.el --- Eshell modules -*- lexical-binding:t -*- |
affbf647 | 2 | |
ab422c4d | 3 | ;; Copyright (C) 1999-2000, 2002-2013 Free Software Foundation, Inc. |
affbf647 | 4 | |
04f9dc47 SM |
5 | ;; Author: John Wiegley <johnw@gnu.org> |
6 | ;; Keywords: processes | |
04f9dc47 | 7 | |
affbf647 GM |
8 | ;; This file is part of GNU Emacs. |
9 | ||
4ee57b2a | 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
affbf647 | 11 | ;; it under the terms of the GNU General Public License as published by |
4ee57b2a GM |
12 | ;; the Free Software Foundation, either version 3 of the License, or |
13 | ;; (at your option) any later version. | |
affbf647 GM |
14 | |
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
4ee57b2a | 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
affbf647 | 22 | |
fa31eac3 GM |
23 | ;;; Code: |
24 | ||
affbf647 GM |
25 | (provide 'esh-module) |
26 | ||
4184766e | 27 | (require 'eshell) |
fa31eac3 | 28 | (require 'esh-util) |
affbf647 GM |
29 | |
30 | (defgroup eshell-module nil | |
31 | "The `eshell-module' group is for Eshell extension modules, which | |
32 | provide optional behavior which the user can enable or disable by | |
33 | customizing the variable `eshell-modules-list'." | |
34 | :tag "Extension modules" | |
35 | :group 'eshell) | |
36 | ||
affbf647 GM |
37 | ;; load the defgroup's for the standard extension modules, so that |
38 | ;; documentation can be provided when the user customize's | |
35ff222c GM |
39 | ;; `eshell-modules-list'. We use "(progn (defgroup ..." in each file |
40 | ;; to force the autoloader into including the entire defgroup, rather | |
41 | ;; than an abbreviated version. | |
d3d5f4f5 | 42 | (load "esh-groups" nil 'nomessage) |
affbf647 GM |
43 | |
44 | ;;; User Variables: | |
45 | ||
46 | (defcustom eshell-module-unload-hook | |
47 | '(eshell-unload-extension-modules) | |
4a0f18a8 | 48 | "A hook run when `eshell-module' is unloaded." |
affbf647 GM |
49 | :type 'hook |
50 | :group 'eshell-module) | |
51 | ||
52 | (defcustom eshell-modules-list | |
53 | '(eshell-alias | |
54 | eshell-banner | |
55 | eshell-basic | |
56 | eshell-cmpl | |
57 | eshell-dirs | |
58 | eshell-glob | |
59 | eshell-hist | |
60 | eshell-ls | |
61 | eshell-pred | |
62 | eshell-prompt | |
63 | eshell-script | |
64 | eshell-term | |
65 | eshell-unix) | |
4a0f18a8 | 66 | "A list of optional add-on modules to be loaded by Eshell. |
affbf647 GM |
67 | Changes will only take effect in future Eshell buffers." |
68 | :type (append | |
69 | (list 'set ':tag "Supported modules") | |
70 | (mapcar | |
71 | (function | |
72 | (lambda (modname) | |
73 | (let ((modsym (intern modname))) | |
74 | (list 'const | |
75 | ':tag (format "%s -- %s" modname | |
76 | (get modsym 'custom-tag)) | |
77 | ':link (caar (get modsym 'custom-links)) | |
78 | ':doc (concat "\n" (get modsym 'group-documentation) | |
79 | "\n ") | |
80 | modsym)))) | |
81 | (sort (mapcar 'symbol-name | |
82 | (eshell-subgroups 'eshell-module)) | |
83 | 'string-lessp)) | |
84 | '((repeat :inline t :tag "Other modules" symbol))) | |
85 | :group 'eshell-module) | |
86 | ||
87 | ;;; Code: | |
88 | ||
89 | (defsubst eshell-using-module (module) | |
90 | "Return non-nil if a certain Eshell MODULE is in use. | |
91 | The MODULE should be a symbol corresponding to that module's | |
92 | customization group. Example: `eshell-cmpl' for that module." | |
93 | (memq module eshell-modules-list)) | |
94 | ||
95 | (defun eshell-unload-extension-modules () | |
96 | "Unload any memory resident extension modules." | |
a9eeff78 | 97 | (dolist (module (eshell-subgroups 'eshell-module)) |
affbf647 GM |
98 | (if (featurep module) |
99 | (ignore-errors | |
100 | (message "Unloading %s..." (symbol-name module)) | |
101 | (unload-feature module) | |
102 | (message "Unloading %s...done" (symbol-name module)))))) | |
103 | ||
104 | ;;; esh-module.el ends here |