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, or (at your option)
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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
36 (defgroup eshell-module nil
37 "The `eshell-module' group is for Eshell extension modules, which
38 provide optional behavior which the user can enable or disable by
39 customizing the variable `eshell-modules-list'."
40 :tag
"Extension modules"
44 (defun eshell-load-defgroups (&optional directory
)
45 "Load `defgroup' statements from Eshell's module files."
46 (let ((vc-handled-backends nil
)) ; avoid VC fucking things up
48 (find-file-noselect (expand-file-name "esh-groups.el" directory
))
50 (insert ";;; do not modify this file; it is auto-generated -*- no-byte-compile: t -*-\n\n")
51 (let ((files (directory-files (or directory
52 (car command-line-args-left
))
53 nil
"\\`em-.*\\.el\\'")))
55 (message "Loading defgroup from `%s'" (car files
))
58 (with-current-buffer (find-file-noselect (car files
))
59 (goto-char (point-min))
62 (if (eobp) (throw 'handled t
))
65 (defg (looking-at "(defgroup")))
68 (setq defgroup
(buffer-substring begin
(point))))))))
70 (insert defgroup
"\n\n")))
71 (setq files
(cdr files
))))
72 ;; Don't make backups, to avoid prompting the user if there are
73 ;; excess backup versions.
76 ;; load the defgroup's for the standard extension modules, so that
77 ;; documentation can be provided when the user customize's
78 ;; `eshell-modules-list'.
80 (when (and (boundp 'byte-compile-current-file
)
81 byte-compile-current-file
83 (equal (file-name-nondirectory byte-compile-current-file
)
85 ;; When eshell file names are expanded from a wildcard
86 ;; or by reading the Eshell directory, e.g. when they
87 ;; say "make recompile" in the lisp directory, Emacs on
88 ;; MS-DOS sees a truncated name "esh-modu.el" instead of
90 (and (fboundp 'msdos-long-file-names
)
91 (null (msdos-long-file-names))
92 (equal (file-name-nondirectory byte-compile-current-file
)
94 (let* ((directory (file-name-directory byte-compile-current-file
))
95 (elc-file (expand-file-name "esh-groups.elc" directory
)))
96 (eshell-load-defgroups directory
)
97 (if (file-exists-p elc-file
) (delete-file elc-file
)))))
99 (load "esh-groups" t t
)
103 (defcustom eshell-module-unload-hook
104 '(eshell-unload-extension-modules)
105 "*A hook run when `eshell-module' is unloaded."
107 :group
'eshell-module
)
109 (defcustom eshell-modules-list
123 "*A list of optional add-on modules to be loaded by Eshell.
124 Changes will only take effect in future Eshell buffers."
126 (list 'set
':tag
"Supported modules")
130 (let ((modsym (intern modname
)))
132 ':tag
(format "%s -- %s" modname
133 (get modsym
'custom-tag
))
134 ':link
(caar (get modsym
'custom-links
))
135 ':doc
(concat "\n" (get modsym
'group-documentation
)
138 (sort (mapcar 'symbol-name
139 (eshell-subgroups 'eshell-module
))
141 '((repeat :inline t
:tag
"Other modules" symbol
)))
142 :group
'eshell-module
)
146 (defsubst eshell-using-module
(module)
147 "Return non-nil if a certain Eshell MODULE is in use.
148 The MODULE should be a symbol corresponding to that module's
149 customization group. Example: `eshell-cmpl' for that module."
150 (memq module eshell-modules-list
))
152 (defun eshell-unload-extension-modules ()
153 "Unload any memory resident extension modules."
154 (eshell-for module
(eshell-subgroups 'eshell-module
)
155 (if (featurep module
)
157 (message "Unloading %s..." (symbol-name module
))
158 (unload-feature module
)
159 (message "Unloading %s...done" (symbol-name module
))))))
161 ;; arch-tag: 97a3fa16-9d08-40e6-bc2c-36bd70986507
162 ;;; esh-module.el ends here