Mercurial > emacs
annotate lisp/eshell/esh-module.el @ 95109:88a6289c23cb
(destructuring-bind): Fix spec.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 19 May 2008 11:58:43 +0000 |
parents | b5b0801a7637 |
children | 1b1b163d3028 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33020
diff
changeset
|
1 ;;; esh-module.el --- Eshell modules |
29876 | 2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004, |
79707 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
29876 | 5 |
29898
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
6 ;; Author: John Wiegley <johnw@gnu.org> |
8f071fd1161d
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29876
diff
changeset
|
7 ;; Keywords: processes |
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 | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
29876 | 12 ;; it under the terms of the GNU General Public License as published by |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
29876 | 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 | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
29876 | 23 |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
24 ;;; Code: |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
25 |
29876 | 26 (provide 'esh-module) |
27 | |
33020 | 28 (eval-when-compile |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
29 (require 'cl) |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
30 (require 'esh-util)) |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
31 |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
32 (require 'esh-util) |
29876 | 33 |
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" | |
39 :group 'eshell) | |
40 | |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
41 (eval-and-compile |
29876 | 42 (defun eshell-load-defgroups (&optional directory) |
43 "Load `defgroup' statements from Eshell's module files." | |
56027
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
44 (let ((vc-handled-backends nil)) ; avoid VC fucking things up |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
45 (with-current-buffer |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
46 (find-file-noselect (expand-file-name "esh-groups.el" directory)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
47 (erase-buffer) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
48 (insert ";;; do not modify this file; it is auto-generated -*- no-byte-compile: t -*-\n\n") |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
49 (let ((files (directory-files (or directory |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
50 (car command-line-args-left)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
51 nil "\\`em-.*\\.el\\'"))) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
52 (while files |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
53 (message "Loading defgroup from `%s'" (car files)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
54 (let (defgroup) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
55 (catch 'handled |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
56 (with-current-buffer (find-file-noselect (car files)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
57 (goto-char (point-min)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
58 (while t |
29876 | 59 (forward-sexp) |
56027
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
60 (if (eobp) (throw 'handled t)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
61 (backward-sexp) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
62 (let ((begin (point)) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
63 (defg (looking-at "(defgroup"))) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
64 (forward-sexp) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
65 (if defg |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
66 (setq defgroup (buffer-substring begin (point)))))))) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
67 (if defgroup |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
68 (insert defgroup "\n\n"))) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
69 (setq files (cdr files)))) |
86198
69eed007ab4b
(eshell-load-defgroups): Don't make backups when saving esh-groups.el.
Eli Zaretskii <eliz@gnu.org>
parents:
78220
diff
changeset
|
70 ;; Don't make backups, to avoid prompting the user if there are |
69eed007ab4b
(eshell-load-defgroups): Don't make backups when saving esh-groups.el.
Eli Zaretskii <eliz@gnu.org>
parents:
78220
diff
changeset
|
71 ;; excess backup versions. |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
72 (save-buffer 0))))) |
29876 | 73 |
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'. | |
77 (eval-when-compile | |
30141 | 78 (when (and (boundp 'byte-compile-current-file) |
79 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
|
80 (or |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
81 (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
|
82 "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
|
83 ;; 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
|
84 ;; 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
|
85 ;; 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
|
86 ;; 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
|
87 ;; "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
|
88 (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
|
89 (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
|
90 (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
|
91 "esh-modu.el")))) |
29876 | 92 (let* ((directory (file-name-directory byte-compile-current-file)) |
33020 | 93 (elc-file (expand-file-name "esh-groups.elc" directory))) |
29876 | 94 (eshell-load-defgroups directory) |
95 (if (file-exists-p elc-file) (delete-file elc-file))))) | |
96 | |
97 (load "esh-groups" t t) | |
98 | |
99 ;;; User Variables: | |
100 | |
101 (defcustom eshell-module-unload-hook | |
102 '(eshell-unload-extension-modules) | |
103 "*A hook run when `eshell-module' is unloaded." | |
104 :type 'hook | |
105 :group 'eshell-module) | |
106 | |
107 (defcustom eshell-modules-list | |
108 '(eshell-alias | |
109 eshell-banner | |
110 eshell-basic | |
111 eshell-cmpl | |
112 eshell-dirs | |
113 eshell-glob | |
114 eshell-hist | |
115 eshell-ls | |
116 eshell-pred | |
117 eshell-prompt | |
118 eshell-script | |
119 eshell-term | |
120 eshell-unix) | |
121 "*A list of optional add-on modules to be loaded by Eshell. | |
122 Changes will only take effect in future Eshell buffers." | |
123 :type (append | |
124 (list 'set ':tag "Supported modules") | |
125 (mapcar | |
126 (function | |
127 (lambda (modname) | |
128 (let ((modsym (intern modname))) | |
129 (list 'const | |
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) | |
134 "\n ") | |
135 modsym)))) | |
136 (sort (mapcar 'symbol-name | |
137 (eshell-subgroups 'eshell-module)) | |
138 'string-lessp)) | |
139 '((repeat :inline t :tag "Other modules" symbol))) | |
140 :group 'eshell-module) | |
141 | |
142 ;;; Code: | |
143 | |
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)) | |
149 | |
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) | |
154 (ignore-errors | |
155 (message "Unloading %s..." (symbol-name module)) | |
156 (unload-feature module) | |
157 (message "Unloading %s...done" (symbol-name module)))))) | |
158 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
159 ;; arch-tag: 97a3fa16-9d08-40e6-bc2c-36bd70986507 |
29876 | 160 ;;; esh-module.el ends here |