aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1993-02-17 21:30:21 +0000
committerRoland McGrath1993-02-17 21:30:21 +0000
commit7e4263eb77b4403b445509047fa4154845050269 (patch)
tree0a1f7d86a897e0544c663a3e51157b22fe5eb8e5
parenteceee2c04a26e60fc91636fc527c86d1a9722289 (diff)
downloademacs-7e4263eb77b4403b445509047fa4154845050269.tar.gz
emacs-7e4263eb77b4403b445509047fa4154845050269.zip
(generate-file-autoloads): If no buffer was visiting FILE when we started,
kill the buffer we create.
-rw-r--r--lisp/emacs-lisp/autoload.el125
1 files changed, 66 insertions, 59 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 117e8355f67..b44042f4622 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -1,6 +1,6 @@
1;;; autoload.el --- maintain autoloads in loaddefs.el. 1;;; autoload.el --- maintain autoloads in loaddefs.el.
2 2
3;;; Copyright (C) 1991, 1992 Free Software Foundation, Inc. 3;;; Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
4;;; 4;;;
5;; Author: Roland McGrath <roland@gnu.ai.mit.edu> 5;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
6;; Keyword: internal 6;; Keyword: internal
@@ -96,7 +96,6 @@ If FILE is being visited in a buffer, the contents of the buffer
96are used." 96are used."
97 (interactive "fGenerate autoloads for file: ") 97 (interactive "fGenerate autoloads for file: ")
98 (let ((outbuf (current-buffer)) 98 (let ((outbuf (current-buffer))
99 (inbuf (find-file-noselect file))
100 (autoloads-done '()) 99 (autoloads-done '())
101 (load-name (let ((name (file-name-nondirectory file))) 100 (load-name (let ((name (file-name-nondirectory file)))
102 (if (string-match "\\.elc?$" name) 101 (if (string-match "\\.elc?$" name)
@@ -105,6 +104,7 @@ are used."
105 (print-length nil) 104 (print-length nil)
106 (floating-output-format "%20e") 105 (floating-output-format "%20e")
107 (done-any nil) 106 (done-any nil)
107 (visited (get-file-buffer file))
108 output-end) 108 output-end)
109 109
110 ;; If the autoload section we create here uses an absolute 110 ;; If the autoload section we create here uses an absolute
@@ -122,63 +122,70 @@ are used."
122 (setq file (substring file (length default-directory))))) 122 (setq file (substring file (length default-directory)))))
123 123
124 (message "Generating autoloads for %s..." file) 124 (message "Generating autoloads for %s..." file)
125 (save-excursion 125 (unwind-protect
126 (set-buffer inbuf) 126 (progn
127 (save-excursion 127 (set-buffer (find-file-noselect file))
128 (save-restriction 128 (save-excursion
129 (widen) 129 (save-restriction
130 (goto-char (point-min)) 130 (widen)
131 (while (not (eobp)) 131 (goto-char (point-min))
132 (skip-chars-forward " \t\n\f") 132 (while (not (eobp))
133 (cond ((looking-at (regexp-quote generate-autoload-cookie)) 133 (skip-chars-forward " \t\n\f")
134 (search-forward generate-autoload-cookie) 134 (cond ((looking-at (regexp-quote generate-autoload-cookie))
135 (skip-chars-forward " \t") 135 (search-forward generate-autoload-cookie)
136 (setq done-any t) 136 (skip-chars-forward " \t")
137 (if (eolp) 137 (setq done-any t)
138 ;; Read the next form and make an autoload. 138 (if (eolp)
139 (let* ((form (prog1 (read (current-buffer)) 139 ;; Read the next form and make an autoload.
140 (forward-line 1))) 140 (let* ((form (prog1 (read (current-buffer))
141 (autoload (make-autoload form load-name)) 141 (forward-line 1)))
142 (doc-string-elt (get (car-safe form) 142 (autoload (make-autoload form load-name))
143 'doc-string-elt))) 143 (doc-string-elt (get (car-safe form)
144 (if autoload 144 'doc-string-elt)))
145 (setq autoloads-done (cons (nth 1 form) 145 (if autoload
146 autoloads-done)) 146 (setq autoloads-done (cons (nth 1 form)
147 (setq autoload form)) 147 autoloads-done))
148 (if (and doc-string-elt 148 (setq autoload form))
149 (stringp (nth doc-string-elt autoload))) 149 (if (and doc-string-elt
150 ;; We need to hack the printing because the 150 (stringp (nth doc-string-elt autoload)))
151 ;; doc-string must be printed specially for 151 ;; We need to hack the printing because the
152 ;; make-docfile (sigh). 152 ;; doc-string must be printed specially for
153 (let* ((p (nthcdr (1- doc-string-elt) autoload)) 153 ;; make-docfile (sigh).
154 (elt (cdr p))) 154 (let* ((p (nthcdr (1- doc-string-elt)
155 (setcdr p nil) 155 autoload))
156 (princ "\n(" outbuf) 156 (elt (cdr p)))
157 (mapcar (function (lambda (elt) 157 (setcdr p nil)
158 (prin1 elt outbuf) 158 (princ "\n(" outbuf)
159 (princ " " outbuf))) 159 (mapcar (function (lambda (elt)
160 autoload) 160 (prin1 elt outbuf)
161 (princ "\"\\\n" outbuf) 161 (princ " " outbuf)))
162 (princ (substring (prin1-to-string (car elt)) 1) 162 autoload)
163 outbuf) 163 (princ "\"\\\n" outbuf)
164 (if (null (cdr elt)) 164 (princ (substring
165 (princ ")" outbuf) 165 (prin1-to-string (car elt)) 1)
166 (princ " " outbuf) 166 outbuf)
167 (princ (substring (prin1-to-string (cdr elt)) 167 (if (null (cdr elt))
168 1) 168 (princ ")" outbuf)
169 outbuf)) 169 (princ " " outbuf)
170 (terpri outbuf)) 170 (princ (substring
171 (print autoload outbuf))) 171 (prin1-to-string (cdr elt))
172 ;; Copy the rest of the line to the output. 172 1)
173 (let ((begin (point))) 173 outbuf))
174 (forward-line 1) 174 (terpri outbuf))
175 (princ (buffer-substring begin (point)) outbuf)))) 175 (print autoload outbuf)))
176 ((looking-at ";") 176 ;; Copy the rest of the line to the output.
177 ;; Don't read the comment. 177 (let ((begin (point)))
178 (forward-line 1)) 178 (forward-line 1)
179 (t 179 (princ (buffer-substring begin (point)) outbuf))))
180 (forward-sexp 1) 180 ((looking-at ";")
181 (forward-line 1)))))) 181 ;; Don't read the comment.
182 (forward-line 1))
183 (t
184 (forward-sexp 1)
185 (forward-line 1)))))))
186 (or visited
187 ;; We created this buffer, so we should kill it.
188 (kill-buffer (current-buffer)))
182 (set-buffer outbuf) 189 (set-buffer outbuf)
183 (setq output-end (point-marker))) 190 (setq output-end (point-marker)))
184 (if done-any 191 (if done-any