comparison lisp/autoload.el @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 74fd4e045ea6
children de805c49cfc1
comparison
equal deleted inserted replaced
405:0e08f63c74d2 406:b8cc9ab3f761
112 (put 'defmacro 'doc-string-elt 3) 112 (put 'defmacro 'doc-string-elt 3)
113 113
114 (defun autoload-trim-file-name (file) 114 (defun autoload-trim-file-name (file)
115 "Returns a relative pathname of FILE including the last directory." 115 "Returns a relative pathname of FILE including the last directory."
116 (setq file (expand-file-name file)) 116 (setq file (expand-file-name file))
117 (file-relative-name file (file-name-directory 117 (replace-in-string
118 (directory-file-name 118 (file-relative-name file (file-name-directory
119 (file-name-directory file))))) 119 (directory-file-name
120 120 (file-name-directory file))))
121 "\\\\" "/"))
122
121 ;;;###autoload 123 ;;;###autoload
122 (defun generate-file-autoloads (file &optional funlist) 124 (defun generate-file-autoloads (file &optional funlist)
123 "Insert at point a loaddefs autoload section for FILE. 125 "Insert at point a loaddefs autoload section for FILE.
124 autoloads are generated for defuns and defmacros in FILE 126 autoloads are generated for defuns and defmacros in FILE
125 marked by `generate-autoload-cookie' (which see). 127 marked by `generate-autoload-cookie' (which see).
337 339
338 (defconst autoload-file-name "auto-autoloads.el" 340 (defconst autoload-file-name "auto-autoloads.el"
339 "Generic filename to put autoloads into. 341 "Generic filename to put autoloads into.
340 Unless you are an XEmacs maintainer, it is probably unwise to change this.") 342 Unless you are an XEmacs maintainer, it is probably unwise to change this.")
341 343
342 (defvar autoload-target-directory "../lisp/prim/" 344 (defvar autoload-target-directory "../lisp/"
343 "Directory to put autoload declaration file into. 345 "Directory to put autoload declaration file into.
344 Unless you know what you're doing, don't mess with this.") 346 Unless you know what you're doing, don't mess with this.")
345 347
346 (defvar generated-autoload-file 348 (defvar generated-autoload-file
347 (expand-file-name (concat autoload-target-directory 349 (expand-file-name (concat autoload-target-directory
348 autoload-file-name) 350 autoload-file-name)
349 data-directory) 351 data-directory)
350 "*File `update-file-autoloads' puts autoloads into. 352 "*File `update-file-autoloads' puts autoloads into.
351 A .el file can set this in its local variables section to make its 353 A .el file can set this in its local variables section to make its
352 autoloads go somewhere else.") 354 autoloads go somewhere else.
355
356 Note that `batch-update-directory' binds this variable to its own value,
357 generally the file named `autoload-file-name' in the directory being
358 updated.")
353 359
354 (defconst cusload-file-name "custom-load.el" 360 (defconst cusload-file-name "custom-load.el"
355 "Generic filename ot put custom loads into. 361 "Generic filename ot put custom loads into.
356 Unless you are an XEmacs maintainr, it is probably unwise to change this.") 362 Unless you are an XEmacs maintainr, it is probably unwise to change this.")
357 363
456 462
457 ;;;###autoload 463 ;;;###autoload
458 (defun update-autoloads-from-directory (dir) 464 (defun update-autoloads-from-directory (dir)
459 "Update `generated-autoload-file' with all the current autoloads from DIR. 465 "Update `generated-autoload-file' with all the current autoloads from DIR.
460 This runs `update-file-autoloads' on each .el file in DIR. 466 This runs `update-file-autoloads' on each .el file in DIR.
461 Obsolete autoload entries for files that no longer exist are deleted." 467 Obsolete autoload entries for files that no longer exist are deleted.
468 Note that, if this function is called from `batch-update-directory',
469 `generated-autoload-file' was rebound in that function."
462 (interactive "DUpdate autoloads for directory: ") 470 (interactive "DUpdate autoloads for directory: ")
463 (setq dir (expand-file-name dir)) 471 (setq dir (expand-file-name dir))
464 (let ((simple-dir (file-name-as-directory 472 (let ((simple-dir (file-name-as-directory
465 (file-name-nondirectory 473 (file-name-nondirectory
466 (directory-file-name dir)))) 474 (directory-file-name dir))))
532 (goto-char (point-max)) 540 (goto-char (point-max))
533 (insert "\n(provide '" sym ")\n"))))) 541 (insert "\n(provide '" sym ")\n")))))
534 542
535 (defvar autoload-package-name nil) 543 (defvar autoload-package-name nil)
536 544
545 ;; #### this function is almost identical, but subtly different,
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
537 ;;;###autoload 550 ;;;###autoload
538 (defun batch-update-directory () 551 (defun batch-update-directory ()
539 "Update the autoloads for the directory on the command line. 552 "Update the autoloads for the directories on the command line.
540 Runs `update-file-autoloads' on each file in the given directory, must 553 Runs `update-file-autoloads' on each file in the given directory, and must
541 be used only with -batch and kills XEmacs on completion." 554 be used only with -batch."
542 (unless noninteractive 555 (unless noninteractive
543 (error "batch-update-directory is to be used only with -batch")) 556 (error "batch-update-directory is to be used only with -batch"))
544 (let ((defdir default-directory) 557 (let ((defdir default-directory)
545 (enable-local-eval nil)) ; Don't query in batch mode. 558 (enable-local-eval nil)) ; Don't query in batch mode.
546 (dolist (arg command-line-args-left) 559 (dolist (arg command-line-args-left)
547 (setq arg (expand-file-name arg defdir)) 560 (setq arg (expand-file-name arg defdir))
548 (let ((generated-autoload-file (concat arg "/" autoload-file-name))) 561 (let ((generated-autoload-file (expand-file-name autoload-file-name
562 arg)))
549 (cond 563 (cond
550 ((file-directory-p arg) 564 ((file-directory-p arg)
551 (message "Updating autoloads in directory %s..." arg) 565 (message "Updating autoloads in directory %s..." arg)
552 (update-autoloads-from-directory arg)) 566 (update-autoloads-from-directory arg))
553 (t (error "No such file or directory: %s" arg))) 567 (t (error "No such file or directory: %s" arg)))
559 ;; (message "Done") 573 ;; (message "Done")
560 ;; (kill-emacs 0) 574 ;; (kill-emacs 0)
561 ) 575 )
562 (setq command-line-args-left nil))) 576 (setq command-line-args-left nil)))
563 577
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
564 (provide 'autoload) 608 (provide 'autoload)
565 609
566 ;;; autoload.el ends here 610 ;;; autoload.el ends here