1 ;;; esh-module.el --- Eshell modules
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: John Wiegley <johnw@gnu.org>
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/>.
34 (defgroup eshell-module nil
35 "The `eshell-module' group is for Eshell extension modules, which
36 provide optional behavior which the user can enable or disable by
37 customizing the variable `eshell-modules-list'."
38 :tag
"Extension modules"
42 (defun eshell-load-defgroups (&optional directory
)
43 "Load `defgroup' statements from Eshell's module files."
44 (let ((vc-handled-backends nil
)) ; avoid VC fucking things up
46 (find-file-noselect (expand-file-name "esh-groups.el" directory
))
48 (insert ";;; do not modify this file; it is auto-generated -*- no-byte-compile: t -*-\n\n")
49 (let ((files (directory-files (or directory
50 (car command-line-args-left
))
51 nil
"\\`em-.*\\.el\\'")))
53 (message "Loading defgroup from `%s'" (car files
))
56 (with-current-buffer (find-file-noselect (car files
))
57 (goto-char (point-min))
60 (if (eobp) (throw 'handled t
))
63 (defg (looking-at "(defgroup")))
66 (setq defgroup
(buffer-substring begin
(point))))))))
68 (insert defgroup
"\n\n")))
69 (setq files
(cdr files
))))
70 ;; Don't make backups, to avoid prompting the user if there are
71 ;; excess backup versions.
74 ;; load the defgroup's for the standard extension modules, so that
75 ;; documentation can be provided when the user customize's
76 ;; `eshell-modules-list'.
78 (when (and (boundp 'byte-compile-current-file
)
79 byte-compile-current-file
81 (equal (file-name-nondirectory byte-compile-current-file
)
83 ;; When eshell file names are expanded from a wildcard
84 ;; or by reading the Eshell directory, e.g. when they
85 ;; say "make recompile" in the lisp directory, Emacs on
86 ;; MS-DOS sees a truncated name "esh-modu.el" instead of
88 (and (fboundp 'msdos-long-file-names
)
89 (null (msdos-long-file-names))
90 (equal (file-name-nondirectory byte-compile-current-file
)
92 (let* ((directory (file-name-directory byte-compile-current-file
))
93 (elc-file (expand-file-name "esh-groups.elc" directory
)))
94 (eshell-load-defgroups directory
)
95 (if (file-exists-p elc-file
) (delete-file elc-file
)))))
97 (load "esh-groups" t t
)
101 (defcustom eshell-module-unload-hook
102 '(eshell-unload-extension-modules)
103 "*A hook run when `eshell-module' is unloaded."
105 :group
'eshell-module
)
107 (defcustom eshell-modules-list
121 "*A list of optional add-on modules to be loaded by Eshell.
122 Changes will only take effect in future Eshell buffers."
124 (list 'set
':tag
"Supported modules")
128 (let ((modsym (intern modname
)))
130 ':tag
(format "%s -- %s" modname
131 (get modsym
'custom-tag
))
132 ':link
(caar (get modsym
'custom-links
))
133 ':doc
(concat "\n" (get modsym
'group-documentation
)
136 (sort (mapcar 'symbol-name
137 (eshell-subgroups 'eshell-module
))
139 '((repeat :inline t
:tag
"Other modules" symbol
)))
140 :group
'eshell-module
)
144 (defsubst eshell-using-module
(module)
145 "Return non-nil if a certain Eshell MODULE is in use.
146 The MODULE should be a symbol corresponding to that module's
147 customization group. Example: `eshell-cmpl' for that module."
148 (memq module eshell-modules-list
))
150 (defun eshell-unload-extension-modules ()
151 "Unload any memory resident extension modules."
152 (eshell-for module
(eshell-subgroups 'eshell-module
)
153 (if (featurep module
)
155 (message "Unloading %s..." (symbol-name module
))
156 (unload-feature module
)
157 (message "Unloading %s...done" (symbol-name module
))))))
159 ;; arch-tag: 97a3fa16-9d08-40e6-bc2c-36bd70986507
160 ;;; esh-module.el ends here