Mercurial > emacs
comparison lisp/emacs-lisp/autoload.el @ 81607:56b815dd1abb
(autoload-generate-file-autoloads): Make `outbuf' optional.
(update-file-autoloads): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 25 Jun 2007 16:19:05 +0000 |
parents | feafa882a0cf |
children | 9d32dd7131c3 |
comparison
equal
deleted
inserted
replaced
81606:19ee9b6ece0e | 81607:56b815dd1abb |
---|---|
309 are used. | 309 are used. |
310 Return non-nil in the case where no autoloads were added at point." | 310 Return non-nil in the case where no autoloads were added at point." |
311 (interactive "fGenerate autoloads for file: ") | 311 (interactive "fGenerate autoloads for file: ") |
312 (autoload-generate-file-autoloads file (current-buffer))) | 312 (autoload-generate-file-autoloads file (current-buffer))) |
313 | 313 |
314 (defun autoload-generate-file-autoloads (file outbuf) | 314 (defun autoload-generate-file-autoloads (file &optional outbuf) |
315 "Insert an autoload section for FILE in the appropriate buffer. | 315 "Insert an autoload section for FILE in the appropriate buffer. |
316 Autoloads are generated for defuns and defmacros in FILE | 316 Autoloads are generated for defuns and defmacros in FILE |
317 marked by `generate-autoload-cookie' (which see). | 317 marked by `generate-autoload-cookie' (which see). |
318 If FILE is being visited in a buffer, the contents of the buffer are used. | 318 If FILE is being visited in a buffer, the contents of the buffer are used. |
319 OUTBUF is the buffer in which the autoload statements will be inserted. | 319 OUTBUF is the buffer in which the autoload statements will be inserted. |
320 Return non-nil in the case where no autoloads were added in the buffer." | 320 If OUTBUF is nil, it will be determined by `autoload-generated-file'. |
321 Return non-nil in the case where no autoloads were added to OUTBUF. | |
322 | |
323 Can throw `up-to-date' to mean that the entries were found already and are | |
324 up-to-date. Of course, this can only be the case if OUTBUF is not used." | |
321 (let ((autoloads-done '()) | 325 (let ((autoloads-done '()) |
322 (load-name (autoload-file-load-name file)) | 326 (load-name (autoload-file-load-name file)) |
323 (print-length nil) | 327 (print-length nil) |
324 (print-readably t) ; This does something in Lucid Emacs. | 328 (print-readably t) ; This does something in Lucid Emacs. |
325 (float-output-format nil) | 329 (float-output-format nil) |
343 (skip-chars-forward " \t\n\f") | 347 (skip-chars-forward " \t\n\f") |
344 (cond | 348 (cond |
345 ((looking-at (regexp-quote generate-autoload-cookie)) | 349 ((looking-at (regexp-quote generate-autoload-cookie)) |
346 ;; If not done yet, figure out where to insert this text. | 350 ;; If not done yet, figure out where to insert this text. |
347 (unless output-start | 351 (unless output-start |
352 (unless outbuf | |
353 (setq outbuf (autoload-find-destination absfile))) | |
348 (with-current-buffer outbuf | 354 (with-current-buffer outbuf |
349 (setq relfile (file-relative-name absfile)) | 355 (setq relfile (file-relative-name absfile)) |
350 (setq output-start (point))) | 356 (setq output-start (point))) |
351 ;; (message "file=%S, relfile=%S, dest=%S" | 357 ;; (message "file=%S, relfile=%S, dest=%S" |
352 ;; file relfile (autoload-generated-file)) | 358 ;; file relfile (autoload-generated-file)) |
416 If SAVE-AFTER is non-nil (which is always, when called interactively), | 422 If SAVE-AFTER is non-nil (which is always, when called interactively), |
417 save the buffer too. | 423 save the buffer too. |
418 | 424 |
419 Return FILE if there was no autoload cookie in it, else nil." | 425 Return FILE if there was no autoload cookie in it, else nil." |
420 (interactive "fUpdate autoloads for file: \np") | 426 (interactive "fUpdate autoloads for file: \np") |
421 (let ((existing-buffer (get-file-buffer file)) | 427 (let ((no-autoloads nil)) |
422 (no-autoloads nil)) | 428 (if (catch 'up-to-date |
423 (with-temp-buffer | 429 (progn |
424 ;; Let's presume the file is not visited, so we call | 430 (setq no-autoloads (autoload-generate-file-autoloads file)) |
425 ;; autoload-find-destination from a dummy buffer, except if the file | 431 t)) |
426 ;; is visited, in which case we use that buffer instead. | 432 (if save-after (autoload-save-buffers)) |
427 (if existing-buffer (set-buffer existing-buffer)) | 433 (if (interactive-p) |
428 | 434 (message "Autoload section for %s is up to date." file))) |
429 (if (catch 'up-to-date | |
430 (with-current-buffer (autoload-find-destination file) | |
431 (setq no-autoloads (generate-file-autoloads file)) | |
432 t)) | |
433 (if save-after (autoload-save-buffers)) | |
434 (if (interactive-p) | |
435 (message "Autoload section for %s is up to date." file)))) | |
436 ;; If we caught `up-to-date', it means there are autoload entries, since | 435 ;; If we caught `up-to-date', it means there are autoload entries, since |
437 ;; otherwise we wouldn't have detected their up-to-dateness. | 436 ;; otherwise we wouldn't have detected their up-to-dateness. |
438 (if no-autoloads file))) | 437 (if no-autoloads file))) |
439 | 438 |
440 (defun autoload-find-destination (file) | 439 (defun autoload-find-destination (file) |