diff options
| author | Karl Heuer | 1998-04-12 06:46:08 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-04-12 06:46:08 +0000 |
| commit | 2336b6a9cea42d75b846c146e2a06cf90568136a (patch) | |
| tree | aa2fcc4255932d3ef2bed42d1d5635efddf51551 | |
| parent | b5231eda99a3833d0eebacdd188763c76f943e03 (diff) | |
| download | emacs-2336b6a9cea42d75b846c146e2a06cf90568136a.tar.gz emacs-2336b6a9cea42d75b846c146e2a06cf90568136a.zip | |
(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.
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 1a85cd7c688..1bce589cc8c 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el | |||
| @@ -51,12 +51,14 @@ 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.") |
| 59 | 58 | ||
| 59 | (defconst generate-autoload-section-continuation ";;;;;; " | ||
| 60 | "String to add on each continuation of the section header form.") | ||
| 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." |
| @@ -132,6 +134,27 @@ Returns nil if FORM is not a defun, define-skeleton, defmacro or defcustom." | |||
| 132 | (file-relative-name file | 134 | (file-relative-name file |
| 133 | (file-name-directory generated-autoload-file))) | 135 | (file-name-directory generated-autoload-file))) |
| 134 | 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)))))) | ||
| 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 |
| @@ -269,12 +292,24 @@ are used." | |||
| 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 |
| @@ -325,9 +360,7 @@ are used." | |||
| 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. |
| @@ -394,7 +427,9 @@ Autoload section for %s is up to date." | |||
| 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) |
| @@ -420,9 +455,7 @@ This uses `update-file-autoloads' (which see) do its work." | |||
| 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))) |