Mercurial > emacs
comparison lisp/emacs-lisp/autoload.el @ 1975:3334e2489824
* autoload.el (generate-file-autoloads): Add another
save-excursion so that point is before the generated autoloads
after we scan the file.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 02 Mar 1993 07:21:44 +0000 |
parents | 4a8bc12e7017 |
children | 2c7997f249eb |
comparison
equal
deleted
inserted
replaced
1974:94e4f619080b | 1975:3334e2489824 |
---|---|
120 (substring file 0 (length default-directory)))) | 120 (substring file 0 (length default-directory)))) |
121 (progn | 121 (progn |
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 (unwind-protect | 125 (save-excursion |
126 (progn | 126 (unwind-protect |
127 (set-buffer (find-file-noselect file)) | 127 (progn |
128 (save-excursion | 128 (set-buffer (find-file-noselect file)) |
129 (save-restriction | 129 (save-excursion |
130 (widen) | 130 (save-restriction |
131 (goto-char (point-min)) | 131 (widen) |
132 (while (not (eobp)) | 132 (goto-char (point-min)) |
133 (skip-chars-forward " \t\n\f") | 133 (while (not (eobp)) |
134 (cond ((looking-at (regexp-quote generate-autoload-cookie)) | 134 (skip-chars-forward " \t\n\f") |
135 (search-forward generate-autoload-cookie) | 135 (cond |
136 (skip-chars-forward " \t") | 136 ((looking-at (regexp-quote generate-autoload-cookie)) |
137 (setq done-any t) | 137 (search-forward generate-autoload-cookie) |
138 (if (eolp) | 138 (skip-chars-forward " \t") |
139 ;; Read the next form and make an autoload. | 139 (setq done-any t) |
140 (let* ((form (prog1 (read (current-buffer)) | 140 (if (eolp) |
141 (forward-line 1))) | 141 ;; Read the next form and make an autoload. |
142 (autoload (make-autoload form load-name)) | 142 (let* ((form (prog1 (read (current-buffer)) |
143 (doc-string-elt (get (car-safe form) | 143 (forward-line 1))) |
144 'doc-string-elt))) | 144 (autoload (make-autoload form load-name)) |
145 (if autoload | 145 (doc-string-elt (get (car-safe form) |
146 (setq autoloads-done (cons (nth 1 form) | 146 'doc-string-elt))) |
147 autoloads-done)) | 147 (if autoload |
148 (setq autoload form)) | 148 (setq autoloads-done (cons (nth 1 form) |
149 (if (and doc-string-elt | 149 autoloads-done)) |
150 (stringp (nth doc-string-elt autoload))) | 150 (setq autoload form)) |
151 ;; We need to hack the printing because the | 151 (if (and doc-string-elt |
152 ;; doc-string must be printed specially for | 152 (stringp (nth doc-string-elt autoload))) |
153 ;; make-docfile (sigh). | 153 ;; We need to hack the printing because the |
154 (let* ((p (nthcdr (1- doc-string-elt) | 154 ;; doc-string must be printed specially for |
155 autoload)) | 155 ;; make-docfile (sigh). |
156 (elt (cdr p))) | 156 (let* ((p (nthcdr (1- doc-string-elt) |
157 (setcdr p nil) | 157 autoload)) |
158 (princ "\n(" outbuf) | 158 (elt (cdr p))) |
159 (mapcar (function (lambda (elt) | 159 (setcdr p nil) |
160 (prin1 elt outbuf) | 160 (princ "\n(" outbuf) |
161 (princ " " outbuf))) | 161 (mapcar (function (lambda (elt) |
162 autoload) | 162 (prin1 elt outbuf) |
163 (princ "\"\\\n" outbuf) | 163 (princ " " outbuf))) |
164 (princ (substring | 164 autoload) |
165 (prin1-to-string (car elt)) 1) | 165 (princ "\"\\\n" outbuf) |
166 outbuf) | 166 (princ (substring |
167 (if (null (cdr elt)) | 167 (prin1-to-string (car elt)) 1) |
168 (princ ")" outbuf) | 168 outbuf) |
169 (princ " " outbuf) | 169 (if (null (cdr elt)) |
170 (princ (substring | 170 (princ ")" outbuf) |
171 (prin1-to-string (cdr elt)) | 171 (princ " " outbuf) |
172 1) | 172 (princ (substring |
173 outbuf)) | 173 (prin1-to-string (cdr elt)) |
174 (terpri outbuf)) | 174 1) |
175 (print autoload outbuf))) | 175 outbuf)) |
176 ;; Copy the rest of the line to the output. | 176 (terpri outbuf)) |
177 (let ((begin (point))) | 177 (print autoload outbuf))) |
178 (forward-line 1) | 178 ;; Copy the rest of the line to the output. |
179 (princ (buffer-substring begin (point)) outbuf)))) | 179 (let ((begin (point))) |
180 ((looking-at ";") | 180 (forward-line 1) |
181 ;; Don't read the comment. | 181 (princ (buffer-substring begin (point)) outbuf)))) |
182 (forward-line 1)) | 182 ((looking-at ";") |
183 (t | 183 ;; Don't read the comment. |
184 (forward-sexp 1) | 184 (forward-line 1)) |
185 (forward-line 1))))))) | 185 (t |
186 (or visited | 186 (forward-sexp 1) |
187 ;; We created this buffer, so we should kill it. | 187 (forward-line 1))))))) |
188 (kill-buffer (current-buffer))) | 188 (or visited |
189 (set-buffer outbuf) | 189 ;; We created this buffer, so we should kill it. |
190 (setq output-end (point-marker))) | 190 (kill-buffer (current-buffer))) |
191 (set-buffer outbuf) | |
192 (setq output-end (point-marker)))) | |
191 (if done-any | 193 (if done-any |
192 (progn | 194 (progn |
193 (insert generate-autoload-section-header) | 195 (insert generate-autoload-section-header) |
194 (prin1 (list 'autoloads autoloads-done load-name file | 196 (prin1 (list 'autoloads autoloads-done load-name file |
195 (nth 5 (file-attributes file))) | 197 (nth 5 (file-attributes file))) |