diff options
| author | Stefan Monnier | 2007-06-26 19:53:12 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-06-26 19:53:12 +0000 |
| commit | 438d6bb6065ba62ecb4ee9c9c2adefca9ade3272 (patch) | |
| tree | 03b17f150691d75225ce4d6a0683bc8b4e78f308 /lisp | |
| parent | 1fad2b12bad86310146e4e579501407ab55819f5 (diff) | |
| download | emacs-438d6bb6065ba62ecb4ee9c9c2adefca9ade3272.tar.gz emacs-438d6bb6065ba62ecb4ee9c9c2adefca9ade3272.zip | |
(autoload-generated-file): Interpret names relative to current dir
for file-local settings.
(autoload-generate-file-autoloads): Add `outfile' arg.
(update-directory-autoloads): Use it to directly call
autoload-generate-file-autoloads instead of going through
update-file-autoloads so we avoid redundant searches and so we can know
the set of buffers changed so we can save them all.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 71 |
2 files changed, 61 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 958b962c522..52e077e5a90 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2007-06-26 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2007-06-26 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/autoload.el (autoload-generated-file): Interpret names | ||
| 4 | relative to current dir for file-local settings. | ||
| 5 | (autoload-generate-file-autoloads): Add `outfile' arg. | ||
| 6 | (update-directory-autoloads): Use it to directly call | ||
| 7 | autoload-generate-file-autoloads instead of going through | ||
| 8 | update-file-autoloads so we avoid redundant searches and so we can know | ||
| 9 | the set of buffers changed so we can save them all. | ||
| 10 | |||
| 3 | * emacs-lisp/autoload.el (autoload-find-destination): Return nil | 11 | * emacs-lisp/autoload.el (autoload-find-destination): Return nil |
| 4 | rather than throwing `up-to-date'. | 12 | rather than throwing `up-to-date'. |
| 5 | (autoload-generate-file-autoloads): Adjust correspondingly. | 13 | (autoload-generate-file-autoloads): Adjust correspondingly. |
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index c0362f3e6f6..e9c05d48c65 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el | |||
| @@ -156,8 +156,12 @@ or macro definition or a defcustom)." | |||
| 156 | 156 | ||
| 157 | (defun autoload-generated-file () | 157 | (defun autoload-generated-file () |
| 158 | (expand-file-name generated-autoload-file | 158 | (expand-file-name generated-autoload-file |
| 159 | (expand-file-name "lisp" | 159 | ;; File-local settings of generated-autoload-file should |
| 160 | source-directory))) | 160 | ;; be interpreted relative to the file's location, |
| 161 | ;; of course. | ||
| 162 | (if (not (local-variable-p 'generated-autoload-file)) | ||
| 163 | (expand-file-name "lisp" source-directory)))) | ||
| 164 | |||
| 161 | 165 | ||
| 162 | (defun autoload-read-section-header () | 166 | (defun autoload-read-section-header () |
| 163 | "Read a section header form. | 167 | "Read a section header form. |
| @@ -301,15 +305,26 @@ Return non-nil in the case where no autoloads were added at point." | |||
| 301 | (interactive "fGenerate autoloads for file: ") | 305 | (interactive "fGenerate autoloads for file: ") |
| 302 | (autoload-generate-file-autoloads file (current-buffer))) | 306 | (autoload-generate-file-autoloads file (current-buffer))) |
| 303 | 307 | ||
| 304 | (defun autoload-generate-file-autoloads (file &optional outbuf) | 308 | ;; When called from `generate-file-autoloads' we should ignore |
| 309 | ;; `generated-autoload-file' altogether. When called from | ||
| 310 | ;; `update-file-autoloads' we don't know `outbuf'. And when called from | ||
| 311 | ;; `update-directory-autoloads' it's in between: we know the default | ||
| 312 | ;; `outbuf' but we should obey any file-local setting of | ||
| 313 | ;; `generated-autoload-file'. | ||
| 314 | (defun autoload-generate-file-autoloads (file &optional outbuf outfile) | ||
| 305 | "Insert an autoload section for FILE in the appropriate buffer. | 315 | "Insert an autoload section for FILE in the appropriate buffer. |
| 306 | Autoloads are generated for defuns and defmacros in FILE | 316 | Autoloads are generated for defuns and defmacros in FILE |
| 307 | marked by `generate-autoload-cookie' (which see). | 317 | marked by `generate-autoload-cookie' (which see). |
| 308 | 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. |
| 309 | OUTBUF is the buffer in which the autoload statements will be inserted. | 319 | OUTBUF is the buffer in which the autoload statements should be inserted. |
| 310 | If OUTBUF is nil, it will be determined by `autoload-generated-file'. | 320 | If OUTBUF is nil, it will be determined by `autoload-generated-file'. |
| 311 | 321 | ||
| 312 | Return non-nil iff FILE adds no autoloads to OUTBUF." | 322 | If provided, OUTFILE is expected to be the file name of OUTBUF. |
| 323 | If OUTFILE is non-nil and FILE specifies a `generated-autoload-file' | ||
| 324 | different from OUTFILE, then OUTBUF is ignored. | ||
| 325 | |||
| 326 | Return non-nil iff FILE adds no autoloads to OUTFILE | ||
| 327 | \(or OUTBUF if OUTFILE is nil)." | ||
| 313 | (catch 'done | 328 | (catch 'done |
| 314 | (let ((autoloads-done '()) | 329 | (let ((autoloads-done '()) |
| 315 | (load-name (autoload-file-load-name file)) | 330 | (load-name (autoload-file-load-name file)) |
| @@ -317,6 +332,7 @@ Return non-nil iff FILE adds no autoloads to OUTBUF." | |||
| 317 | (print-readably t) ; This does something in Lucid Emacs. | 332 | (print-readably t) ; This does something in Lucid Emacs. |
| 318 | (float-output-format nil) | 333 | (float-output-format nil) |
| 319 | (visited (get-file-buffer file)) | 334 | (visited (get-file-buffer file)) |
| 335 | (otherbuf nil) | ||
| 320 | (absfile (expand-file-name file)) | 336 | (absfile (expand-file-name file)) |
| 321 | relfile | 337 | relfile |
| 322 | ;; nil until we found a cookie. | 338 | ;; nil until we found a cookie. |
| @@ -338,12 +354,20 @@ Return non-nil iff FILE adds no autoloads to OUTBUF." | |||
| 338 | ((looking-at (regexp-quote generate-autoload-cookie)) | 354 | ((looking-at (regexp-quote generate-autoload-cookie)) |
| 339 | ;; If not done yet, figure out where to insert this text. | 355 | ;; If not done yet, figure out where to insert this text. |
| 340 | (unless output-start | 356 | (unless output-start |
| 357 | (when (and outfile | ||
| 358 | (not (equal outfile (autoload-generated-file)))) | ||
| 359 | ;; A file-local setting of autoload-generated-file says | ||
| 360 | ;; we should ignore OUTBUF. | ||
| 361 | (setq outbuf nil) | ||
| 362 | (setq otherbuf t)) | ||
| 341 | (unless outbuf | 363 | (unless outbuf |
| 342 | (setq outbuf (autoload-find-destination absfile)) | 364 | (setq outbuf (autoload-find-destination absfile)) |
| 343 | (unless outbuf | 365 | (unless outbuf |
| 344 | ;; The file has autoload cookies, but they're | 366 | ;; The file has autoload cookies, but they're |
| 345 | ;; already up-to-date. | 367 | ;; already up-to-date. If OUTFILE is nil, the |
| 346 | (throw 'done t))) | 368 | ;; entries are in the expected OUTBUF, otherwise |
| 369 | ;; they're elsewhere. | ||
| 370 | (throw 'done outfile))) | ||
| 347 | (with-current-buffer outbuf | 371 | (with-current-buffer outbuf |
| 348 | (setq relfile (file-relative-name absfile)) | 372 | (setq relfile (file-relative-name absfile)) |
| 349 | (setq output-start (point))) | 373 | (setq output-start (point))) |
| @@ -399,7 +423,9 @@ Return non-nil iff FILE adds no autoloads to OUTBUF." | |||
| 399 | (or visited | 423 | (or visited |
| 400 | ;; We created this buffer, so we should kill it. | 424 | ;; We created this buffer, so we should kill it. |
| 401 | (kill-buffer (current-buffer)))) | 425 | (kill-buffer (current-buffer)))) |
| 402 | (not output-start)))) | 426 | ;; If the entries were added to some other buffer, then the file |
| 427 | ;; doesn't add entries to OUTFILE. | ||
| 428 | (or (not output-start) otherbuf)))) | ||
| 403 | 429 | ||
| 404 | (defun autoload-save-buffers () | 430 | (defun autoload-save-buffers () |
| 405 | (while autoload-modified-buffers | 431 | (while autoload-modified-buffers |
| @@ -511,12 +537,14 @@ directory or directories specified." | |||
| 511 | t files-re)) | 537 | t files-re)) |
| 512 | dirs))) | 538 | dirs))) |
| 513 | (this-time (current-time)) | 539 | (this-time (current-time)) |
| 514 | (no-autoloads nil) ;files with no autoload cookies. | 540 | ;; Files with no autoload cookies or whose autoloads go to other |
| 515 | (autoloads-file (autoload-generated-file)) | 541 | ;; files because of file-local autoload-generated-file settings. |
| 516 | (top-dir (file-name-directory autoloads-file))) | 542 | (no-autoloads nil) |
| 543 | (autoload-modified-buffers nil)) | ||
| 517 | 544 | ||
| 518 | (with-current-buffer | 545 | (with-current-buffer |
| 519 | (find-file-noselect (autoload-ensure-default-file autoloads-file)) | 546 | (find-file-noselect |
| 547 | (autoload-ensure-default-file (autoload-generated-file))) | ||
| 520 | (save-excursion | 548 | (save-excursion |
| 521 | 549 | ||
| 522 | ;; Canonicalize file names and remove the autoload file itself. | 550 | ;; Canonicalize file names and remove the autoload file itself. |
| @@ -541,19 +569,23 @@ directory or directories specified." | |||
| 541 | (push file no-autoloads) | 569 | (push file no-autoloads) |
| 542 | (setq files (delete file files))))))) | 570 | (setq files (delete file files))))))) |
| 543 | ((not (stringp file))) | 571 | ((not (stringp file))) |
| 544 | ((not (file-exists-p (expand-file-name file top-dir))) | 572 | ((not (file-exists-p file)) |
| 545 | ;; Remove the obsolete section. | 573 | ;; Remove the obsolete section. |
| 546 | (autoload-remove-section (match-beginning 0))) | 574 | (autoload-remove-section (match-beginning 0))) |
| 547 | ((equal (nth 4 form) (nth 5 (file-attributes file))) | 575 | ((equal (nth 4 form) (nth 5 (file-attributes file))) |
| 548 | ;; File hasn't changed. | 576 | ;; File hasn't changed. |
| 549 | nil) | 577 | nil) |
| 550 | (t | 578 | (t |
| 551 | (update-file-autoloads file))) | 579 | (autoload-remove-section (match-beginning 0)) |
| 580 | (if (autoload-generate-file-autoloads | ||
| 581 | file (current-buffer) buffer-file-name) | ||
| 582 | (push file no-autoloads)))) | ||
| 552 | (setq files (delete file files))))) | 583 | (setq files (delete file files))))) |
| 553 | ;; Elements remaining in FILES have no existing autoload sections yet. | 584 | ;; Elements remaining in FILES have no existing autoload sections yet. |
| 554 | (setq no-autoloads | 585 | (dolist (file files) |
| 555 | (append no-autoloads | 586 | (if (autoload-generate-file-autoloads file nil buffer-file-name) |
| 556 | (delq nil (mapcar 'update-file-autoloads files)))) | 587 | (push file no-autoloads))) |
| 588 | |||
| 557 | (when no-autoloads | 589 | (when no-autoloads |
| 558 | ;; Sort them for better readability. | 590 | ;; Sort them for better readability. |
| 559 | (setq no-autoloads (sort no-autoloads 'string<)) | 591 | (setq no-autoloads (sort no-autoloads 'string<)) |
| @@ -564,7 +596,10 @@ directory or directories specified." | |||
| 564 | (current-buffer) nil nil no-autoloads this-time) | 596 | (current-buffer) nil nil no-autoloads this-time) |
| 565 | (insert generate-autoload-section-trailer)) | 597 | (insert generate-autoload-section-trailer)) |
| 566 | 598 | ||
| 567 | (save-buffer)))) | 599 | (save-buffer) |
| 600 | ;; In case autoload entries were added to other files because of | ||
| 601 | ;; file-local autoload-generated-file settings. | ||
| 602 | (autoload-save-buffers)))) | ||
| 568 | 603 | ||
| 569 | (define-obsolete-function-alias 'update-autoloads-from-directories | 604 | (define-obsolete-function-alias 'update-autoloads-from-directories |
| 570 | 'update-directory-autoloads "22.1") | 605 | 'update-directory-autoloads "22.1") |