Mercurial > emacs
comparison lisp/emacs-lisp/autoload.el @ 21479:89c1bfb63571
(generate-autoload-section-header): Doc fix.
(update-file-autoloads): Use autoload-read-section-header.
(update-autoloads-from-directories): Likewise.
(generate-autoload-section-continuation): New variable.
(autoload-read-section-header): New function.
(update-file-autoloads): Don't call save-buffer if no changes.
(generate-file-autoloads): Split the section header line
into multiple comments.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sun, 12 Apr 1998 06:46:08 +0000 |
parents | 9ca6953d7ce8 |
children | ea83fc4c4f77 |
comparison
equal
deleted
inserted
replaced
21478:54680b998295 | 21479:89c1bfb63571 |
---|---|
49 If this string appears alone on a line, the following form will be | 49 If this string appears alone on a line, the following form will be |
50 read and an autoload made for it. If there is further text on the line, | 50 read and an autoload made for it. If there is further text on the line, |
51 that text will be copied verbatim to `generated-autoload-file'.") | 51 that text will be copied verbatim to `generated-autoload-file'.") |
52 | 52 |
53 (defconst generate-autoload-section-header "\f\n;;;### " | 53 (defconst generate-autoload-section-header "\f\n;;;### " |
54 "String inserted before the form identifying | 54 "String that marks the form at the start of a new file's autoload section.") |
55 the section of autoloads for a file.") | |
56 | 55 |
57 (defconst generate-autoload-section-trailer "\n;;;***\n" | 56 (defconst generate-autoload-section-trailer "\n;;;***\n" |
58 "String which indicates the end of the section of autoloads for a file.") | 57 "String which indicates the end of the section of autoloads for a file.") |
58 | |
59 (defconst generate-autoload-section-continuation ";;;;;; " | |
60 "String to add on each continuation of the section header form.") | |
59 | 61 |
60 (defun make-autoload (form file) | 62 (defun make-autoload (form file) |
61 "Turn FORM into an autoload or defvar for source file FILE. | 63 "Turn FORM into an autoload or defvar for source file FILE. |
62 Returns nil if FORM is not a defun, define-skeleton, defmacro or defcustom." | 64 Returns nil if FORM is not a defun, define-skeleton, defmacro or defcustom." |
63 (let ((car (car-safe form))) | 65 (let ((car (car-safe form))) |
129 ;; which means Emacs will be able to find FILE when it looks. | 131 ;; which means Emacs will be able to find FILE when it looks. |
130 ;; Any extra directory names here would prevent finding the file. | 132 ;; Any extra directory names here would prevent finding the file. |
131 (setq file (expand-file-name file)) | 133 (setq file (expand-file-name file)) |
132 (file-relative-name file | 134 (file-relative-name file |
133 (file-name-directory generated-autoload-file))) | 135 (file-name-directory generated-autoload-file))) |
136 | |
137 (defun autoload-read-section-header () | |
138 "Read a section header form. | |
139 Since continuation lines have been marked as comments, | |
140 we must copy the text of the form and remove those comment | |
141 markers before we call `read'." | |
142 (save-match-data | |
143 (let ((beginning (point)) | |
144 string) | |
145 (forward-line 1) | |
146 (while (looking-at generate-autoload-section-continuation) | |
147 (forward-line 1)) | |
148 (setq string (buffer-substring beginning (point))) | |
149 (with-current-buffer (get-buffer-create " *autoload*") | |
150 (erase-buffer) | |
151 (insert string) | |
152 (goto-char (point-min)) | |
153 (while (search-forward generate-autoload-section-continuation nil t) | |
154 (replace-match " ")) | |
155 (goto-char (point-min)) | |
156 (read (current-buffer)))))) | |
134 | 157 |
135 (defun generate-file-autoloads (file) | 158 (defun generate-file-autoloads (file) |
136 "Insert at point a loaddefs autoload section for FILE. | 159 "Insert at point a loaddefs autoload section for FILE. |
137 autoloads are generated for defuns and defmacros in FILE | 160 autoloads are generated for defuns and defmacros in FILE |
138 marked by `generate-autoload-cookie' (which see). | 161 marked by `generate-autoload-cookie' (which see). |
267 (kill-buffer (current-buffer))) | 290 (kill-buffer (current-buffer))) |
268 (set-buffer outbuf) | 291 (set-buffer outbuf) |
269 (setq output-end (point-marker)))) | 292 (setq output-end (point-marker)))) |
270 (if done-any | 293 (if done-any |
271 (progn | 294 (progn |
295 ;; Insert the section-header line | |
296 ;; which lists the file name and which functions are in it, etc. | |
272 (insert generate-autoload-section-header) | 297 (insert generate-autoload-section-header) |
273 (prin1 (list 'autoloads autoloads-done load-name | 298 (prin1 (list 'autoloads autoloads-done load-name |
274 (autoload-trim-file-name file) | 299 (autoload-trim-file-name file) |
275 (nth 5 (file-attributes file))) | 300 (nth 5 (file-attributes file))) |
276 outbuf) | 301 outbuf) |
277 (terpri outbuf) | 302 (terpri outbuf) |
303 ;; Break that line at spaces, to avoid very long lines. | |
304 ;; Make each sub-line into a comment. | |
305 (with-current-buffer outbuf | |
306 (save-excursion | |
307 (forward-line -1) | |
308 (while (not (eolp)) | |
309 (move-to-column 64) | |
310 (skip-chars-forward "^ \n") | |
311 (or (eolp) | |
312 (insert "\n" generate-autoload-section-continuation))))) | |
278 (insert ";;; Generated autoloads from " | 313 (insert ";;; Generated autoloads from " |
279 (autoload-trim-file-name file) "\n") | 314 (autoload-trim-file-name file) "\n") |
280 ;; Warn if we put a line in loaddefs.el | 315 ;; Warn if we put a line in loaddefs.el |
281 ;; that is long enough to cause trouble. | 316 ;; that is long enough to cause trouble. |
282 (while (< (point) output-end) | 317 (while (< (point) output-end) |
323 (widen) | 358 (widen) |
324 (goto-char (point-min)) | 359 (goto-char (point-min)) |
325 ;; Look for the section for LOAD-NAME. | 360 ;; Look for the section for LOAD-NAME. |
326 (while (and (not found) | 361 (while (and (not found) |
327 (search-forward generate-autoload-section-header nil t)) | 362 (search-forward generate-autoload-section-header nil t)) |
328 (let ((form (condition-case () | 363 (let ((form (autoload-read-section-header))) |
329 (read (current-buffer)) | |
330 (end-of-file nil)))) | |
331 (cond ((string= (nth 2 form) load-name) | 364 (cond ((string= (nth 2 form) load-name) |
332 ;; We found the section for this file. | 365 ;; We found the section for this file. |
333 ;; Check if it is up to date. | 366 ;; Check if it is up to date. |
334 (let ((begin (match-beginning 0)) | 367 (let ((begin (match-beginning 0)) |
335 (last-time (nth 4 form)) | 368 (last-time (nth 4 form)) |
392 (message "%s has no autoloads" file)) | 425 (message "%s has no autoloads" file)) |
393 t) | 426 t) |
394 (or existing-buffer | 427 (or existing-buffer |
395 (kill-buffer (current-buffer)))))))) | 428 (kill-buffer (current-buffer)))))))) |
396 (generate-file-autoloads file)))) | 429 (generate-file-autoloads file)))) |
397 (if (interactive-p) (save-buffer))))) | 430 (and (interactive-p) |
431 (buffer-modified-p) | |
432 (save-buffer))))) | |
398 | 433 |
399 ;;;###autoload | 434 ;;;###autoload |
400 (defun update-autoloads-from-directories (&rest dirs) | 435 (defun update-autoloads-from-directories (&rest dirs) |
401 "\ | 436 "\ |
402 Update loaddefs.el with all the current autoloads from DIRS, and no old ones. | 437 Update loaddefs.el with all the current autoloads from DIRS, and no old ones. |
418 (save-excursion | 453 (save-excursion |
419 (set-buffer (find-file-noselect autoloads-file)) | 454 (set-buffer (find-file-noselect autoloads-file)) |
420 (save-excursion | 455 (save-excursion |
421 (goto-char (point-min)) | 456 (goto-char (point-min)) |
422 (while (search-forward generate-autoload-section-header nil t) | 457 (while (search-forward generate-autoload-section-header nil t) |
423 (let* ((form (condition-case () | 458 (let* ((form (autoload-read-section-header)) |
424 (read (current-buffer)) | |
425 (end-of-file nil))) | |
426 (file (nth 3 form))) | 459 (file (nth 3 form))) |
427 (cond ((not (stringp file))) | 460 (cond ((not (stringp file))) |
428 ((not (file-exists-p (expand-file-name file top-dir))) | 461 ((not (file-exists-p (expand-file-name file top-dir))) |
429 ;; Remove the obsolete section. | 462 ;; Remove the obsolete section. |
430 (let ((begin (match-beginning 0))) | 463 (let ((begin (match-beginning 0))) |