Mercurial > emacs
annotate lisp/eshell/esh-module.el @ 59235:e4a2eb7b1ae5
(require-final-newline): Allow `visit' and `visit-save'.
(mode-require-final-newline): New option.
(after-find-file): Handle require-final-newline with new values.
(basic-save-buffer): Handle new values of require-final-newline.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 31 Dec 2004 14:48:12 +0000 |
parents | a10d964838a7 |
children | 18a818a2ee7c 4c90ffeb71c5 |
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 |
56027
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2004 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 |
29876 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 (provide 'esh-module) | |
26 | |
33020 | 27 (eval-when-compile |
28 (require 'esh-maint) | |
29 (require 'cl)) | |
29876 | 30 |
31 (defgroup eshell-module nil | |
32 "The `eshell-module' group is for Eshell extension modules, which | |
33 provide optional behavior which the user can enable or disable by | |
34 customizing the variable `eshell-modules-list'." | |
35 :tag "Extension modules" | |
36 :group 'eshell) | |
37 | |
38 ;;; Commentary: | |
39 | |
40 (require 'esh-util) | |
41 | |
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)))) |
a10d964838a7
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
70 (save-buffer)))) |
29876 | 71 |
72 ;; load the defgroup's for the standard extension modules, so that | |
73 ;; documentation can be provided when the user customize's | |
74 ;; `eshell-modules-list'. | |
75 (eval-when-compile | |
30141 | 76 (when (and (boundp 'byte-compile-current-file) |
77 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
|
78 (or |
02375e0f6ea7
(eval-when-compile): Don't lose if esh-module.el's file name
Eli Zaretskii <eliz@gnu.org>
parents:
30141
diff
changeset
|
79 (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
|
80 "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
|
81 ;; 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
|
82 ;; 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
|
83 ;; 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
|
84 ;; 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
|
85 ;; "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
|
86 (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
|
87 (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
|
88 (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
|
89 "esh-modu.el")))) |
29876 | 90 (let* ((directory (file-name-directory byte-compile-current-file)) |
33020 | 91 (elc-file (expand-file-name "esh-groups.elc" directory))) |
29876 | 92 (eshell-load-defgroups directory) |
93 (if (file-exists-p elc-file) (delete-file elc-file))))) | |
94 | |
95 (load "esh-groups" t t) | |
96 | |
97 ;;; User Variables: | |
98 | |
99 (defcustom eshell-module-unload-hook | |
100 '(eshell-unload-extension-modules) | |
101 "*A hook run when `eshell-module' is unloaded." | |
102 :type 'hook | |
103 :group 'eshell-module) | |
104 | |
105 (defcustom eshell-modules-list | |
106 '(eshell-alias | |
107 eshell-banner | |
108 eshell-basic | |
109 eshell-cmpl | |
110 eshell-dirs | |
111 eshell-glob | |
112 eshell-hist | |
113 eshell-ls | |
114 eshell-pred | |
115 eshell-prompt | |
116 eshell-script | |
117 eshell-term | |
118 eshell-unix) | |
119 "*A list of optional add-on modules to be loaded by Eshell. | |
120 Changes will only take effect in future Eshell buffers." | |
121 :type (append | |
122 (list 'set ':tag "Supported modules") | |
123 (mapcar | |
124 (function | |
125 (lambda (modname) | |
126 (let ((modsym (intern modname))) | |
127 (list 'const | |
128 ':tag (format "%s -- %s" modname | |
129 (get modsym 'custom-tag)) | |
130 ':link (caar (get modsym 'custom-links)) | |
131 ':doc (concat "\n" (get modsym 'group-documentation) | |
132 "\n ") | |
133 modsym)))) | |
134 (sort (mapcar 'symbol-name | |
135 (eshell-subgroups 'eshell-module)) | |
136 'string-lessp)) | |
137 '((repeat :inline t :tag "Other modules" symbol))) | |
138 :group 'eshell-module) | |
139 | |
140 ;;; Code: | |
141 | |
142 (defsubst eshell-using-module (module) | |
143 "Return non-nil if a certain Eshell MODULE is in use. | |
144 The MODULE should be a symbol corresponding to that module's | |
145 customization group. Example: `eshell-cmpl' for that module." | |
146 (memq module eshell-modules-list)) | |
147 | |
148 (defun eshell-unload-extension-modules () | |
149 "Unload any memory resident extension modules." | |
150 (eshell-for module (eshell-subgroups 'eshell-module) | |
151 (if (featurep module) | |
152 (ignore-errors | |
153 (message "Unloading %s..." (symbol-name module)) | |
154 (unload-feature module) | |
155 (message "Unloading %s...done" (symbol-name module)))))) | |
156 | |
52401 | 157 ;;; arch-tag: 97a3fa16-9d08-40e6-bc2c-36bd70986507 |
29876 | 158 ;;; esh-module.el ends here |