Mercurial > hg > xemacs-beta
comparison lisp/autoload.el @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
85 the section of autoloads for a file.") | 85 the section of autoloads for a file.") |
86 | 86 |
87 (defvar generate-autoload-section-trailer "\n;;;***\n" | 87 (defvar generate-autoload-section-trailer "\n;;;***\n" |
88 "String which indicates the end of the section of autoloads for a file.") | 88 "String which indicates the end of the section of autoloads for a file.") |
89 | 89 |
90 (defvar autoload-package-name nil) | |
91 | |
92 ;;; Forms which have doc-strings which should be printed specially. | 90 ;;; Forms which have doc-strings which should be printed specially. |
93 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is | 91 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is |
94 ;;; the doc-string in FORM. | 92 ;;; the doc-string in FORM. |
95 ;;; | 93 ;;; |
96 ;;; There used to be the following note here: | 94 ;;; There used to be the following note here: |
114 (put 'defmacro 'doc-string-elt 3) | 112 (put 'defmacro 'doc-string-elt 3) |
115 | 113 |
116 (defun autoload-trim-file-name (file) | 114 (defun autoload-trim-file-name (file) |
117 "Returns a relative pathname of FILE including the last directory." | 115 "Returns a relative pathname of FILE including the last directory." |
118 (setq file (expand-file-name file)) | 116 (setq file (expand-file-name file)) |
119 (replace-in-string | 117 (file-relative-name file (file-name-directory |
120 (file-relative-name file (file-name-directory | 118 (directory-file-name |
121 (directory-file-name | 119 (file-name-directory file))))) |
122 (file-name-directory file)))) | 120 |
123 "\\\\" "/")) | |
124 | |
125 ;;;###autoload | 121 ;;;###autoload |
126 (defun generate-file-autoloads (file &optional funlist) | 122 (defun generate-file-autoloads (file &optional funlist) |
127 "Insert at point a loaddefs autoload section for FILE. | 123 "Insert at point a loaddefs autoload section for FILE. |
128 autoloads are generated for defuns and defmacros in FILE | 124 autoloads are generated for defuns and defmacros in FILE |
129 marked by `generate-autoload-cookie' (which see). | 125 marked by `generate-autoload-cookie' (which see). |
341 | 337 |
342 (defconst autoload-file-name "auto-autoloads.el" | 338 (defconst autoload-file-name "auto-autoloads.el" |
343 "Generic filename to put autoloads into. | 339 "Generic filename to put autoloads into. |
344 Unless you are an XEmacs maintainer, it is probably unwise to change this.") | 340 Unless you are an XEmacs maintainer, it is probably unwise to change this.") |
345 | 341 |
346 (defvar autoload-target-directory "../lisp/" | 342 (defvar autoload-target-directory "../lisp/prim/" |
347 "Directory to put autoload declaration file into. | 343 "Directory to put autoload declaration file into. |
348 Unless you know what you're doing, don't mess with this.") | 344 Unless you know what you're doing, don't mess with this.") |
349 | 345 |
350 (defvar generated-autoload-file | 346 (defvar generated-autoload-file |
351 (expand-file-name (concat autoload-target-directory | 347 (expand-file-name (concat autoload-target-directory |
352 autoload-file-name) | 348 autoload-file-name) |
353 data-directory) | 349 data-directory) |
354 "*File `update-file-autoloads' puts autoloads into. | 350 "*File `update-file-autoloads' puts autoloads into. |
355 A .el file can set this in its local variables section to make its | 351 A .el file can set this in its local variables section to make its |
356 autoloads go somewhere else. | 352 autoloads go somewhere else.") |
357 | |
358 Note that `batch-update-directory' binds this variable to its own value, | |
359 generally the file named `autoload-file-name' in the directory being | |
360 updated.") | |
361 | 353 |
362 (defconst cusload-file-name "custom-load.el" | 354 (defconst cusload-file-name "custom-load.el" |
363 "Generic filename ot put custom loads into. | 355 "Generic filename ot put custom loads into. |
364 Unless you are an XEmacs maintainr, it is probably unwise to change this.") | 356 Unless you are an XEmacs maintainr, it is probably unwise to change this.") |
365 | 357 |
366 ;;;###autoload | 358 ;;;###autoload |
367 (defun update-file-autoloads (file) | 359 (defun update-file-autoloads (file) |
368 "Update the autoloads for FILE in `generated-autoload-file' | 360 "Update the autoloads for FILE in `generated-autoload-file' |
369 \(which FILE might bind in its local variables). | 361 \(which FILE might bind in its local variables). |
370 This function refuses to update autoloads files." | 362 This functions refuses to update autoloads files." |
371 (interactive "fUpdate autoloads for file: ") | 363 (interactive "fUpdate autoloads for file: ") |
372 (setq file (expand-file-name file)) | 364 (setq file (expand-file-name file)) |
373 (when (and (file-newer-than-file-p file generated-autoload-file) | 365 (when (and (file-newer-than-file-p file generated-autoload-file) |
374 (not (member (file-name-nondirectory file) | 366 (not (member (file-name-nondirectory file) |
375 (list autoload-file-name)))) | 367 (list autoload-file-name)))) |
464 | 456 |
465 ;;;###autoload | 457 ;;;###autoload |
466 (defun update-autoloads-from-directory (dir) | 458 (defun update-autoloads-from-directory (dir) |
467 "Update `generated-autoload-file' with all the current autoloads from DIR. | 459 "Update `generated-autoload-file' with all the current autoloads from DIR. |
468 This runs `update-file-autoloads' on each .el file in DIR. | 460 This runs `update-file-autoloads' on each .el file in DIR. |
469 Obsolete autoload entries for files that no longer exist are deleted. | 461 Obsolete autoload entries for files that no longer exist are deleted." |
470 Note that, if this function is called from `batch-update-directory', | |
471 `generated-autoload-file' was rebound in that function." | |
472 (interactive "DUpdate autoloads for directory: ") | 462 (interactive "DUpdate autoloads for directory: ") |
473 (setq dir (expand-file-name dir)) | 463 (setq dir (expand-file-name dir)) |
474 (let ((simple-dir (file-name-as-directory | 464 (let ((simple-dir (file-name-as-directory |
475 (file-name-nondirectory | 465 (file-name-nondirectory |
476 (directory-file-name dir)))) | 466 (directory-file-name dir)))) |
540 (insert "(if (featurep '" sym ")") | 530 (insert "(if (featurep '" sym ")") |
541 (insert " (error \"Already loaded\"))\n") | 531 (insert " (error \"Already loaded\"))\n") |
542 (goto-char (point-max)) | 532 (goto-char (point-max)) |
543 (insert "\n(provide '" sym ")\n"))))) | 533 (insert "\n(provide '" sym ")\n"))))) |
544 | 534 |
545 ;; #### this function is almost identical, but subtly different, | 535 (defvar autoload-package-name nil) |
546 ;; from batch-update-autoloads. Steve, it's your responsibility to | |
547 ;; clean this up. The two should be merged, but I'm not sure what | |
548 ;; package-creation scripts out there might be using this. --ben | |
549 | 536 |
550 ;;;###autoload | 537 ;;;###autoload |
551 (defun batch-update-directory () | 538 (defun batch-update-directory () |
552 "Update the autoloads for the directories on the command line. | 539 "Update the autoloads for the directory on the command line. |
553 Runs `update-file-autoloads' on each file in the given directory, and must | 540 Runs `update-file-autoloads' on each file in the given directory, must |
554 be used only with -batch." | 541 be used only with -batch and kills XEmacs on completion." |
555 (unless noninteractive | 542 (unless noninteractive |
556 (error "batch-update-directory is to be used only with -batch")) | 543 (error "batch-update-directory is to be used only with -batch")) |
557 (let ((defdir default-directory) | 544 (let ((defdir default-directory) |
558 (enable-local-eval nil)) ; Don't query in batch mode. | 545 (enable-local-eval nil)) ; Don't query in batch mode. |
559 (dolist (arg command-line-args-left) | 546 (dolist (arg command-line-args-left) |
560 (setq arg (expand-file-name arg defdir)) | 547 (setq arg (expand-file-name arg defdir)) |
561 (let ((generated-autoload-file (expand-file-name autoload-file-name | 548 (let ((generated-autoload-file (concat arg "/" autoload-file-name))) |
562 arg))) | |
563 (cond | 549 (cond |
564 ((file-directory-p arg) | 550 ((file-directory-p arg) |
565 (message "Updating autoloads in directory %s..." arg) | 551 (message "Updating autoloads in directory %s..." arg) |
566 (update-autoloads-from-directory arg)) | 552 (update-autoloads-from-directory arg)) |
567 (t (error "No such file or directory: %s" arg))) | 553 (t (error "No such file or directory: %s" arg))) |
573 ;; (message "Done") | 559 ;; (message "Done") |
574 ;; (kill-emacs 0) | 560 ;; (kill-emacs 0) |
575 ) | 561 ) |
576 (setq command-line-args-left nil))) | 562 (setq command-line-args-left nil))) |
577 | 563 |
578 ;; #### i created the following. this one and the last should be merged into | |
579 ;; batch-update-autoloads. --ben | |
580 | |
581 ;;;###autoload | |
582 (defun batch-update-one-directory () | |
583 "Update the autoloads for a single directory on the command line. | |
584 Runs `update-file-autoloads' on each file in the given directory, and must | |
585 be used only with -batch." | |
586 (unless noninteractive | |
587 (error "batch-update-directory is to be used only with -batch")) | |
588 (let ((defdir default-directory) | |
589 (enable-local-eval nil)) ; Don't query in batch mode. | |
590 (let ((arg (car command-line-args-left))) | |
591 (setq command-line-args-left (cdr command-line-args-left)) | |
592 (setq arg (expand-file-name arg defdir)) | |
593 (let ((generated-autoload-file (expand-file-name autoload-file-name | |
594 arg))) | |
595 (cond | |
596 ((file-directory-p arg) | |
597 (message "Updating autoloads in directory %s..." arg) | |
598 (update-autoloads-from-directory arg)) | |
599 (t (error "No such file or directory: %s" arg))) | |
600 (fixup-autoload-buffer (concat (if autoload-package-name | |
601 autoload-package-name | |
602 (file-name-nondirectory arg)) | |
603 "-autoloads")) | |
604 (save-some-buffers t)) | |
605 ;; (message "Done") | |
606 ))) | |
607 | |
608 (provide 'autoload) | 564 (provide 'autoload) |
609 | 565 |
610 ;;; autoload.el ends here | 566 ;;; autoload.el ends here |