diff options
| author | Chong Yidong | 2011-05-04 11:38:41 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-05-04 11:38:41 -0400 |
| commit | 9ed7c8cbcedaa50750bc1811bda2824e235787e8 (patch) | |
| tree | 293efb1bbabb98f3b558790bdb9cc50939a3bce8 | |
| parent | 0898ca10c0109274d24f91453036c065f9f5c056 (diff) | |
| download | emacs-9ed7c8cbcedaa50750bc1811bda2824e235787e8.tar.gz emacs-9ed7c8cbcedaa50750bc1811bda2824e235787e8.zip | |
Make autoloading commands prompt for autoload file (Bug#7989)
* emacs-lisp/autoload.el (generated-autoload-file): Set to nil.
(autoload-find-generated-file): New function.
(generate-file-autoloads): Bind generated-autoload-file to
buffer-file-name.
(update-file-autoloads, update-directory-autoloads): Use
autoload-find-generated-file. If called interactively, prompt for
output file.
(batch-update-autoloads): Doc fix.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 77 |
2 files changed, 59 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4f6ebe88277..501b4e8babc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2011-05-04 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * emacs-lisp/autoload.el (generated-autoload-file): Set to nil. | ||
| 4 | (autoload-find-generated-file): New function. | ||
| 5 | (generate-file-autoloads): Bind generated-autoload-file to | ||
| 6 | buffer-file-name. | ||
| 7 | (update-file-autoloads, update-directory-autoloads): Use | ||
| 8 | autoload-find-generated-file. If called interactively, prompt for | ||
| 9 | output file (Bug#7989). | ||
| 10 | (batch-update-autoloads): Doc fix. | ||
| 11 | |||
| 1 | 2011-05-04 Juanma Barranquero <lekktu@gmail.com> | 12 | 2011-05-04 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 13 | ||
| 3 | * term/w32-win.el (dynamic-library-alist): Add `gnutls'. | 14 | * term/w32-win.el (dynamic-library-alist): Add `gnutls'. |
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index dffbf3418ca..f8f8d9b00f2 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el | |||
| @@ -34,8 +34,8 @@ | |||
| 34 | (require 'help-fns) ;for help-add-fundoc-usage. | 34 | (require 'help-fns) ;for help-add-fundoc-usage. |
| 35 | (eval-when-compile (require 'cl)) | 35 | (eval-when-compile (require 'cl)) |
| 36 | 36 | ||
| 37 | (defvar generated-autoload-file "loaddefs.el" | 37 | (defvar generated-autoload-file nil |
| 38 | "File \\[update-file-autoloads] puts autoloads into. | 38 | "File into which to write autoload definitions. |
| 39 | A Lisp file can set this in its local variables section to make | 39 | A Lisp file can set this in its local variables section to make |
| 40 | its autoloads go somewhere else. | 40 | its autoloads go somewhere else. |
| 41 | 41 | ||
| @@ -198,6 +198,15 @@ or macro definition or a defcustom)." | |||
| 198 | ;; the doc-string in FORM. | 198 | ;; the doc-string in FORM. |
| 199 | ;; Those properties are now set in lisp-mode.el. | 199 | ;; Those properties are now set in lisp-mode.el. |
| 200 | 200 | ||
| 201 | (defun autoload-find-generated-file () | ||
| 202 | "Visit the autoload file for the current buffer, and return its buffer. | ||
| 203 | If a buffer is visiting the desired autoload file, return it." | ||
| 204 | (let ((enable-local-variables :safe)) | ||
| 205 | ;; We used to use `raw-text' to read this file, but this causes | ||
| 206 | ;; problems when the file contains non-ASCII characters. | ||
| 207 | (find-file-noselect | ||
| 208 | (autoload-ensure-default-file (autoload-generated-file))))) | ||
| 209 | |||
| 201 | (defun autoload-generated-file () | 210 | (defun autoload-generated-file () |
| 202 | (expand-file-name generated-autoload-file | 211 | (expand-file-name generated-autoload-file |
| 203 | ;; File-local settings of generated-autoload-file should | 212 | ;; File-local settings of generated-autoload-file should |
| @@ -389,7 +398,8 @@ If FILE is being visited in a buffer, the contents of the buffer | |||
| 389 | are used. | 398 | are used. |
| 390 | Return non-nil in the case where no autoloads were added at point." | 399 | Return non-nil in the case where no autoloads were added at point." |
| 391 | (interactive "fGenerate autoloads for file: ") | 400 | (interactive "fGenerate autoloads for file: ") |
| 392 | (autoload-generate-file-autoloads file (current-buffer))) | 401 | (let ((generated-autoload-file buffer-file-name)) |
| 402 | (autoload-generate-file-autoloads file (current-buffer)))) | ||
| 393 | 403 | ||
| 394 | (defvar print-readably) | 404 | (defvar print-readably) |
| 395 | 405 | ||
| @@ -550,15 +560,22 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE | |||
| 550 | (save-buffer))))) | 560 | (save-buffer))))) |
| 551 | 561 | ||
| 552 | ;;;###autoload | 562 | ;;;###autoload |
| 553 | (defun update-file-autoloads (file &optional save-after) | 563 | (defun update-file-autoloads (file &optional save-after outfile) |
| 554 | "Update the autoloads for FILE in `generated-autoload-file' | 564 | "Update the autoloads for FILE. |
| 555 | \(which FILE might bind in its local variables). | 565 | If prefix arg SAVE-AFTER is non-nil, save the buffer too. |
| 556 | If SAVE-AFTER is non-nil (which is always, when called interactively), | 566 | |
| 557 | save the buffer too. | 567 | If FILE binds `generated-autoload-file' as a file-local variable, |
| 568 | autoloads are written into that file. Otherwise, the autoloads | ||
| 569 | file is determined by OUTFILE. If called interactively, prompt | ||
| 570 | for OUTFILE; if called from Lisp with OUTFILE nil, use the | ||
| 571 | existing value of `generated-autoload-file'. | ||
| 558 | 572 | ||
| 559 | Return FILE if there was no autoload cookie in it, else nil." | 573 | Return FILE if there was no autoload cookie in it, else nil." |
| 560 | (interactive "fUpdate autoloads for file: \np") | 574 | (interactive (list (read-file-name "Update autoloads for file: ") |
| 561 | (let* ((autoload-modified-buffers nil) | 575 | current-prefix-arg |
| 576 | (read-file-name "Write autoload definitions to file: "))) | ||
| 577 | (let* ((generated-autoload-file (or outfile generated-autoload-file)) | ||
| 578 | (autoload-modified-buffers nil) | ||
| 562 | (no-autoloads (autoload-generate-file-autoloads file))) | 579 | (no-autoloads (autoload-generate-file-autoloads file))) |
| 563 | (if autoload-modified-buffers | 580 | (if autoload-modified-buffers |
| 564 | (if save-after (autoload-save-buffers)) | 581 | (if save-after (autoload-save-buffers)) |
| @@ -576,12 +593,7 @@ removes any prior now out-of-date autoload entries." | |||
| 576 | (let* ((buf (current-buffer)) | 593 | (let* ((buf (current-buffer)) |
| 577 | (existing-buffer (if buffer-file-name buf)) | 594 | (existing-buffer (if buffer-file-name buf)) |
| 578 | (found nil)) | 595 | (found nil)) |
| 579 | (with-current-buffer | 596 | (with-current-buffer (autoload-find-generated-file) |
| 580 | ;; We used to use `raw-text' to read this file, but this causes | ||
| 581 | ;; problems when the file contains non-ASCII characters. | ||
| 582 | (let ((enable-local-variables :safe)) | ||
| 583 | (find-file-noselect | ||
| 584 | (autoload-ensure-default-file (autoload-generated-file)))) | ||
| 585 | ;; This is to make generated-autoload-file have Unix EOLs, so | 597 | ;; This is to make generated-autoload-file have Unix EOLs, so |
| 586 | ;; that it is portable to all platforms. | 598 | ;; that it is portable to all platforms. |
| 587 | (or (eq 0 (coding-system-eol-type buffer-file-coding-system)) | 599 | (or (eq 0 (coding-system-eol-type buffer-file-coding-system)) |
| @@ -640,15 +652,20 @@ removes any prior now out-of-date autoload entries." | |||
| 640 | 652 | ||
| 641 | ;;;###autoload | 653 | ;;;###autoload |
| 642 | (defun update-directory-autoloads (&rest dirs) | 654 | (defun update-directory-autoloads (&rest dirs) |
| 643 | "\ | 655 | "Update autoload definitions for Lisp files in the directories DIRS. |
| 644 | Update loaddefs.el with all the current autoloads from DIRS, and no old ones. | 656 | In an interactive call, you must give one argument, the name of a |
| 645 | This uses `update-file-autoloads' (which see) to do its work. | 657 | single directory. In a call from Lisp, you can supply multiple |
| 646 | In an interactive call, you must give one argument, the name | ||
| 647 | of a single directory. In a call from Lisp, you can supply multiple | ||
| 648 | directories as separate arguments, but this usage is discouraged. | 658 | directories as separate arguments, but this usage is discouraged. |
| 649 | 659 | ||
| 650 | The function does NOT recursively descend into subdirectories of the | 660 | The function does NOT recursively descend into subdirectories of the |
| 651 | directory or directories specified." | 661 | directory or directories specified. |
| 662 | |||
| 663 | In an interactive call, prompt for a default output file for the | ||
| 664 | autoload definitions, and temporarily bind the variable | ||
| 665 | `generated-autoload-file' to this value. When called from Lisp, | ||
| 666 | use the existing value of `generated-autoload-file'. If any Lisp | ||
| 667 | file binds `generated-autoload-file' as a file-local variable, | ||
| 668 | write its autoloads into the specified file instead." | ||
| 652 | (interactive "DUpdate autoloads from directory: ") | 669 | (interactive "DUpdate autoloads from directory: ") |
| 653 | (let* ((files-re (let ((tmp nil)) | 670 | (let* ((files-re (let ((tmp nil)) |
| 654 | (dolist (suf (get-load-suffixes) | 671 | (dolist (suf (get-load-suffixes) |
| @@ -664,14 +681,14 @@ directory or directories specified." | |||
| 664 | ;; Files with no autoload cookies or whose autoloads go to other | 681 | ;; Files with no autoload cookies or whose autoloads go to other |
| 665 | ;; files because of file-local autoload-generated-file settings. | 682 | ;; files because of file-local autoload-generated-file settings. |
| 666 | (no-autoloads nil) | 683 | (no-autoloads nil) |
| 667 | (autoload-modified-buffers nil)) | 684 | (autoload-modified-buffers nil) |
| 685 | (generated-autoload-file | ||
| 686 | (if (called-interactively-p 'interactive) | ||
| 687 | (read-file-name "Write autoload definitions to file: ") | ||
| 688 | generated-autoload-file))) | ||
| 668 | 689 | ||
| 669 | (with-current-buffer | 690 | (with-current-buffer (autoload-find-generated-file) |
| 670 | (let ((enable-local-variables :safe)) | ||
| 671 | (find-file-noselect | ||
| 672 | (autoload-ensure-default-file (autoload-generated-file)))) | ||
| 673 | (save-excursion | 691 | (save-excursion |
| 674 | |||
| 675 | ;; Canonicalize file names and remove the autoload file itself. | 692 | ;; Canonicalize file names and remove the autoload file itself. |
| 676 | (setq files (delete (file-relative-name buffer-file-name) | 693 | (setq files (delete (file-relative-name buffer-file-name) |
| 677 | (mapcar 'file-relative-name files))) | 694 | (mapcar 'file-relative-name files))) |
| @@ -748,7 +765,9 @@ directory or directories specified." | |||
| 748 | ;;;###autoload | 765 | ;;;###autoload |
| 749 | (defun batch-update-autoloads () | 766 | (defun batch-update-autoloads () |
| 750 | "Update loaddefs.el autoloads in batch mode. | 767 | "Update loaddefs.el autoloads in batch mode. |
| 751 | Calls `update-directory-autoloads' on the command line arguments." | 768 | Calls `update-directory-autoloads' on the command line arguments. |
| 769 | Definitions are written to `generated-autoload-file' (which | ||
| 770 | should be non-nil)." | ||
| 752 | ;; For use during the Emacs build process only. | 771 | ;; For use during the Emacs build process only. |
| 753 | (unless autoload-excludes | 772 | (unless autoload-excludes |
| 754 | (let* ((ldir (file-name-directory generated-autoload-file)) | 773 | (let* ((ldir (file-name-directory generated-autoload-file)) |