Mercurial > emacs
annotate lisp/eshell/esh-module.el @ 94416:bfff356815e9
*** empty log message ***
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 27 Apr 2008 18:44:16 +0000 |
parents | 1e3a407766b9 |
children | b5b0801a7637 |
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 | |
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 | |
78220
a1e8300d3c55
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
29876 | 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 | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
29876 | 25 |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
26 ;;; Code: |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
27 |
29876 | 28 (provide 'esh-module) |
29 | |
33020 | 30 (eval-when-compile |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
31 (require 'cl) |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
32 (require 'esh-util)) |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
33 |
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
34 (require 'esh-util) |
29876 | 35 |
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" | |
41 :group 'eshell) | |
42 | |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
43 (eval-and-compile |
29876 | 44 (defun eshell-load-defgroups (&optional directory) |
45 "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
|
46 (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
|
47 (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
|
48 (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
|
49 (erase-buffer) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
50 (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
|
51 (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
|
52 (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
|
53 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
|
54 (while files |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
55 (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
|
56 (let (defgroup) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
57 (catch 'handled |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
58 (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
|
59 (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
|
60 (while t |
29876 | 61 (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
|
62 (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
|
63 (backward-sexp) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
64 (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
|
65 (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
|
66 (forward-sexp) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
67 (if defg |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
68 (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
|
69 (if defgroup |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
70 (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
|
71 (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
|
72 ;; 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
|
73 ;; excess backup versions. |
87081
24280fb751e3
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86198
diff
changeset
|
74 (save-buffer 0))))) |
29876 | 75 |
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'. | |
79 (eval-when-compile | |
30141 | 80 (when (and (boundp 'byte-compile-current-file) |
81 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
|
82 (or |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
83 (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
|
84 "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
|
85 ;; 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
|
86 ;; 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
|
87 ;; 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
|
88 ;; 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
|
89 ;; "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
|
90 (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
|
91 (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
|
92 (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
|
93 "esh-modu.el")))) |
29876 | 94 (let* ((directory (file-name-directory byte-compile-current-file)) |
33020 | 95 (elc-file (expand-file-name "esh-groups.elc" directory))) |
29876 | 96 (eshell-load-defgroups directory) |
97 (if (file-exists-p elc-file) (delete-file elc-file))))) | |
98 | |
99 (load "esh-groups" t t) | |
100 | |
101 ;;; User Variables: | |
102 | |
103 (defcustom eshell-module-unload-hook | |
104 '(eshell-unload-extension-modules) | |
105 "*A hook run when `eshell-module' is unloaded." | |
106 :type 'hook | |
107 :group 'eshell-module) | |
108 | |
109 (defcustom eshell-modules-list | |
110 '(eshell-alias | |
111 eshell-banner | |
112 eshell-basic | |
113 eshell-cmpl | |
114 eshell-dirs | |
115 eshell-glob | |
116 eshell-hist | |
117 eshell-ls | |
118 eshell-pred | |
119 eshell-prompt | |
120 eshell-script | |
121 eshell-term | |
122 eshell-unix) | |
123 "*A list of optional add-on modules to be loaded by Eshell. | |
124 Changes will only take effect in future Eshell buffers." | |
125 :type (append | |
126 (list 'set ':tag "Supported modules") | |
127 (mapcar | |
128 (function | |
129 (lambda (modname) | |
130 (let ((modsym (intern modname))) | |
131 (list 'const | |
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) | |
136 "\n ") | |
137 modsym)))) | |
138 (sort (mapcar 'symbol-name | |
139 (eshell-subgroups 'eshell-module)) | |
140 'string-lessp)) | |
141 '((repeat :inline t :tag "Other modules" symbol))) | |
142 :group 'eshell-module) | |
143 | |
144 ;;; Code: | |
145 | |
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)) | |
151 | |
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) | |
156 (ignore-errors | |
157 (message "Unloading %s..." (symbol-name module)) | |
158 (unload-feature module) | |
159 (message "Unloading %s...done" (symbol-name module)))))) | |
160 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
161 ;; arch-tag: 97a3fa16-9d08-40e6-bc2c-36bd70986507 |
29876 | 162 ;;; esh-module.el ends here |