Mercurial > emacs
annotate lisp/eshell/esh-module.el @ 32302:ef87e043f166
*** empty log message ***
author | Dave Love <fx@gnu.org> |
---|---|
date | Sun, 08 Oct 2000 17:53:13 +0000 |
parents | 02375e0f6ea7 |
children | b09ded79f0f9 |
rev | line source |
---|---|
29876 | 1 ;;; esh-module --- Eshell modules |
2 | |
29934
34b1ab9d583d
Change spelling of the Free Software Foundation.
Gerd Moellmann <gerd@gnu.org>
parents:
29898
diff
changeset
|
3 ;; Copyright (C) 1999, 2000 Free Software Foundation |
29876 | 4 |
29898
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
5 ;; Author: John Wiegley <johnw@gnu.org> |
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
6 ;; Keywords: processes |
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
7 ;; X-URL: http://www.emacs.org/~johnw/eshell.html |
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
8 |
29876 | 9 ;; This file is part of GNU Emacs. |
10 | |
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 2, or (at your option) | |
14 ;; any later version. | |
15 | |
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. | |
20 | |
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., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 (provide 'esh-module) | |
27 | |
29898
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
28 (eval-when-compile (require 'esh-maint) (require 'cl)) |
29876 | 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 | |
37 ;;; Commentary: | |
38 | |
39 (require 'esh-util) | |
40 | |
41 (defun eshell-load-defgroups (&optional directory) | |
42 "Load `defgroup' statements from Eshell's module files." | |
43 (with-current-buffer | |
44 (find-file-noselect (expand-file-name "esh-groups.el" directory)) | |
45 (erase-buffer) | |
46 (insert ";;; do not modify this file; it is auto-generated\n\n") | |
47 (let ((files (directory-files (or directory | |
48 (car command-line-args-left)) | |
49 nil "\\`em-.*\\.el\\'"))) | |
50 (while files | |
51 (message "Loading defgroup from `%s'" (car files)) | |
52 (let (defgroup) | |
53 (catch 'handled | |
54 (with-current-buffer (find-file-noselect (car files)) | |
55 (goto-char (point-min)) | |
56 (while t | |
57 (forward-sexp) | |
58 (if (eobp) (throw 'handled t)) | |
59 (backward-sexp) | |
60 (let ((begin (point)) | |
61 (defg (looking-at "(defgroup"))) | |
62 (forward-sexp) | |
63 (if defg | |
64 (setq defgroup (buffer-substring begin (point)))))))) | |
65 (if defgroup | |
66 (insert defgroup "\n\n"))) | |
67 (setq files (cdr files)))) | |
68 (save-buffer))) | |
69 | |
70 ;; load the defgroup's for the standard extension modules, so that | |
71 ;; documentation can be provided when the user customize's | |
72 ;; `eshell-modules-list'. | |
73 (eval-when-compile | |
30141 | 74 (when (and (boundp 'byte-compile-current-file) |
75 byte-compile-current-file | |
31327
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
76 (or |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
77 (equal (file-name-nondirectory byte-compile-current-file) |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
78 "esh-module.el") |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
79 ;; When eshell file names are expanded from a wildcard |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
80 ;; or by reading the Eshell directory, e.g. when they |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
81 ;; say "make recompile" in the lisp directory, Emacs on |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
82 ;; MS-DOS sees a truncated name "esh-modu.el" instead of |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
83 ;; "esh-module.el". |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
84 (and (fboundp 'msdos-long-file-names) |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
85 (null (msdos-long-file-names)) |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
86 (equal (file-name-nondirectory byte-compile-current-file) |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
87 "esh-modu.el")))) |
29876 | 88 (let* ((directory (file-name-directory byte-compile-current-file)) |
89 (elc-file (expand-file-name "esh-groups.elc" directory))) | |
90 (eshell-load-defgroups directory) | |
91 (if (file-exists-p elc-file) (delete-file elc-file))))) | |
92 | |
93 (load "esh-groups" t t) | |
94 | |
95 ;;; User Variables: | |
96 | |
97 (defcustom eshell-module-unload-hook | |
98 '(eshell-unload-extension-modules) | |
99 "*A hook run when `eshell-module' is unloaded." | |
100 :type 'hook | |
101 :group 'eshell-module) | |
102 | |
103 (defcustom eshell-modules-list | |
104 '(eshell-alias | |
105 eshell-banner | |
106 eshell-basic | |
107 eshell-cmpl | |
108 eshell-dirs | |
109 eshell-glob | |
110 eshell-hist | |
111 eshell-ls | |
112 eshell-pred | |
113 eshell-prompt | |
114 eshell-script | |
115 eshell-term | |
116 eshell-unix) | |
117 "*A list of optional add-on modules to be loaded by Eshell. | |
118 Changes will only take effect in future Eshell buffers." | |
119 :type (append | |
120 (list 'set ':tag "Supported modules") | |
121 (mapcar | |
122 (function | |
123 (lambda (modname) | |
124 (let ((modsym (intern modname))) | |
125 (list 'const | |
126 ':tag (format "%s -- %s" modname | |
127 (get modsym 'custom-tag)) | |
128 ':link (caar (get modsym 'custom-links)) | |
129 ':doc (concat "\n" (get modsym 'group-documentation) | |
130 "\n ") | |
131 modsym)))) | |
132 (sort (mapcar 'symbol-name | |
133 (eshell-subgroups 'eshell-module)) | |
134 'string-lessp)) | |
135 '((repeat :inline t :tag "Other modules" symbol))) | |
136 :group 'eshell-module) | |
137 | |
138 ;;; Code: | |
139 | |
140 (defsubst eshell-using-module (module) | |
141 "Return non-nil if a certain Eshell MODULE is in use. | |
142 The MODULE should be a symbol corresponding to that module's | |
143 customization group. Example: `eshell-cmpl' for that module." | |
144 (memq module eshell-modules-list)) | |
145 | |
146 (defun eshell-unload-extension-modules () | |
147 "Unload any memory resident extension modules." | |
148 (eshell-for module (eshell-subgroups 'eshell-module) | |
149 (if (featurep module) | |
150 (ignore-errors | |
151 (message "Unloading %s..." (symbol-name module)) | |
152 (unload-feature module) | |
153 (message "Unloading %s...done" (symbol-name module)))))) | |
154 | |
155 ;;; esh-module.el ends here |