|
29876
|
1 ;;; esh-module --- Eshell modules
|
|
|
2
|
|
|
3 ;; Copyright (C) 1999, 2000 Free Sofware Foundation
|
|
|
4
|
|
|
5 ;; This file is part of GNU Emacs.
|
|
|
6
|
|
|
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
|
8 ;; it under the terms of the GNU General Public License as published by
|
|
|
9 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
10 ;; any later version.
|
|
|
11
|
|
|
12 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
15 ;; GNU General Public License for more details.
|
|
|
16
|
|
|
17 ;; You should have received a copy of the GNU General Public License
|
|
|
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
20 ;; Boston, MA 02111-1307, USA.
|
|
|
21
|
|
|
22 (provide 'esh-module)
|
|
|
23
|
|
|
24 (eval-when-compile (require 'esh-maint))
|
|
|
25
|
|
|
26 (defgroup eshell-module nil
|
|
|
27 "The `eshell-module' group is for Eshell extension modules, which
|
|
|
28 provide optional behavior which the user can enable or disable by
|
|
|
29 customizing the variable `eshell-modules-list'."
|
|
|
30 :tag "Extension modules"
|
|
|
31 :group 'eshell)
|
|
|
32
|
|
|
33 ;;; Commentary:
|
|
|
34
|
|
|
35 (require 'esh-util)
|
|
|
36
|
|
|
37 (defun eshell-load-defgroups (&optional directory)
|
|
|
38 "Load `defgroup' statements from Eshell's module files."
|
|
|
39 (with-current-buffer
|
|
|
40 (find-file-noselect (expand-file-name "esh-groups.el" directory))
|
|
|
41 (erase-buffer)
|
|
|
42 (insert ";;; do not modify this file; it is auto-generated\n\n")
|
|
|
43 (let ((files (directory-files (or directory
|
|
|
44 (car command-line-args-left))
|
|
|
45 nil "\\`em-.*\\.el\\'")))
|
|
|
46 (while files
|
|
|
47 (message "Loading defgroup from `%s'" (car files))
|
|
|
48 (let (defgroup)
|
|
|
49 (catch 'handled
|
|
|
50 (with-current-buffer (find-file-noselect (car files))
|
|
|
51 (goto-char (point-min))
|
|
|
52 (while t
|
|
|
53 (forward-sexp)
|
|
|
54 (if (eobp) (throw 'handled t))
|
|
|
55 (backward-sexp)
|
|
|
56 (let ((begin (point))
|
|
|
57 (defg (looking-at "(defgroup")))
|
|
|
58 (forward-sexp)
|
|
|
59 (if defg
|
|
|
60 (setq defgroup (buffer-substring begin (point))))))))
|
|
|
61 (if defgroup
|
|
|
62 (insert defgroup "\n\n")))
|
|
|
63 (setq files (cdr files))))
|
|
|
64 (save-buffer)))
|
|
|
65
|
|
|
66 ;; load the defgroup's for the standard extension modules, so that
|
|
|
67 ;; documentation can be provided when the user customize's
|
|
|
68 ;; `eshell-modules-list'.
|
|
|
69 (eval-when-compile
|
|
|
70 (when (equal (file-name-nondirectory byte-compile-current-file)
|
|
|
71 "esh-module.el")
|
|
|
72 (let* ((directory (file-name-directory byte-compile-current-file))
|
|
|
73 (elc-file (expand-file-name "esh-groups.elc" directory)))
|
|
|
74 (eshell-load-defgroups directory)
|
|
|
75 (if (file-exists-p elc-file) (delete-file elc-file)))))
|
|
|
76
|
|
|
77 (load "esh-groups" t t)
|
|
|
78
|
|
|
79 ;;; User Variables:
|
|
|
80
|
|
|
81 (defcustom eshell-module-unload-hook
|
|
|
82 '(eshell-unload-extension-modules)
|
|
|
83 "*A hook run when `eshell-module' is unloaded."
|
|
|
84 :type 'hook
|
|
|
85 :group 'eshell-module)
|
|
|
86
|
|
|
87 (defcustom eshell-modules-list
|
|
|
88 '(eshell-alias
|
|
|
89 eshell-banner
|
|
|
90 eshell-basic
|
|
|
91 eshell-cmpl
|
|
|
92 eshell-dirs
|
|
|
93 eshell-glob
|
|
|
94 eshell-hist
|
|
|
95 eshell-ls
|
|
|
96 eshell-pred
|
|
|
97 eshell-prompt
|
|
|
98 eshell-script
|
|
|
99 eshell-term
|
|
|
100 eshell-unix)
|
|
|
101 "*A list of optional add-on modules to be loaded by Eshell.
|
|
|
102 Changes will only take effect in future Eshell buffers."
|
|
|
103 :type (append
|
|
|
104 (list 'set ':tag "Supported modules")
|
|
|
105 (mapcar
|
|
|
106 (function
|
|
|
107 (lambda (modname)
|
|
|
108 (let ((modsym (intern modname)))
|
|
|
109 (list 'const
|
|
|
110 ':tag (format "%s -- %s" modname
|
|
|
111 (get modsym 'custom-tag))
|
|
|
112 ':link (caar (get modsym 'custom-links))
|
|
|
113 ':doc (concat "\n" (get modsym 'group-documentation)
|
|
|
114 "\n ")
|
|
|
115 modsym))))
|
|
|
116 (sort (mapcar 'symbol-name
|
|
|
117 (eshell-subgroups 'eshell-module))
|
|
|
118 'string-lessp))
|
|
|
119 '((repeat :inline t :tag "Other modules" symbol)))
|
|
|
120 :group 'eshell-module)
|
|
|
121
|
|
|
122 ;;; Code:
|
|
|
123
|
|
|
124 (defsubst eshell-using-module (module)
|
|
|
125 "Return non-nil if a certain Eshell MODULE is in use.
|
|
|
126 The MODULE should be a symbol corresponding to that module's
|
|
|
127 customization group. Example: `eshell-cmpl' for that module."
|
|
|
128 (memq module eshell-modules-list))
|
|
|
129
|
|
|
130 (defun eshell-unload-extension-modules ()
|
|
|
131 "Unload any memory resident extension modules."
|
|
|
132 (eshell-for module (eshell-subgroups 'eshell-module)
|
|
|
133 (if (featurep module)
|
|
|
134 (ignore-errors
|
|
|
135 (message "Unloading %s..." (symbol-name module))
|
|
|
136 (unload-feature module)
|
|
|
137 (message "Unloading %s...done" (symbol-name module))))))
|
|
|
138
|
|
|
139 ;;; esh-module.el ends here
|