/[emacs]/emacs/lisp/emacs-lisp/autoload.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/autoload.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.87 by rms, Wed Jan 16 02:36:29 2002 UTC revision 1.87.4.1 by miles, Fri Apr 4 06:20:16 2003 UTC
# Line 33  Line 33 
33  ;;; Code:  ;;; Code:
34    
35  (require 'lisp-mode)                    ;for `doc-string-elt' properties.  (require 'lisp-mode)                    ;for `doc-string-elt' properties.
36    (require 'help-fns)                     ;for help-add-fundoc-usage.
37    
38  (defvar generated-autoload-file "loaddefs.el"  (defvar generated-autoload-file "loaddefs.el"
39     "*File \\[update-file-autoloads] puts autoloads into.     "*File \\[update-file-autoloads] puts autoloads into.
# Line 90  or macro definition or a defcustom)." Line 90  or macro definition or a defcustom)."
90                     define-minor-mode defun* defmacro*))                     define-minor-mode defun* defmacro*))
91        (let* ((macrop (memq car '(defmacro defmacro*)))        (let* ((macrop (memq car '(defmacro defmacro*)))
92               (name (nth 1 form))               (name (nth 1 form))
93                 (args (if (memq car '(defun defmacro defun* defmacro*))
94                           (nth 2 form) t))
95               (body (nthcdr (get car 'doc-string-elt) form))               (body (nthcdr (get car 'doc-string-elt) form))
96               (doc (if (stringp (car body)) (pop body))))               (doc (if (stringp (car body)) (pop body))))
97            (when (listp args)
98              ;; Add the usage form at the end where describe-function-1
99              ;; can recover it.
100              (setq doc (help-add-fundoc-usage doc args)))
101          ;; `define-generic-mode' quotes the name, so take care of that          ;; `define-generic-mode' quotes the name, so take care of that
102          (list 'autoload (if (listp name) name (list 'quote name)) file doc          (list 'autoload (if (listp name) name (list 'quote name)) file doc
103                (or (and (memq car '(define-skeleton define-derived-mode                (or (and (memq car '(define-skeleton define-derived-mode
# Line 102  or macro definition or a defcustom)." Line 108  or macro definition or a defcustom)."
108                    (eq (car-safe (car body)) 'interactive))                    (eq (car-safe (car body)) 'interactive))
109                (if macrop (list 'quote 'macro) nil))))                (if macrop (list 'quote 'macro) nil))))
110    
111       ;; Convert defcustom to a simpler (and less space-consuming) defvar,       ;; Convert defcustom to less space-consuming data.
      ;; but add some extra stuff if it uses :require.  
112       ((eq car 'defcustom)       ((eq car 'defcustom)
113        (let ((varname (car-safe (cdr-safe form)))        (let ((varname (car-safe (cdr-safe form)))
114              (init (car-safe (cdr-safe (cdr-safe form))))              (init (car-safe (cdr-safe (cdr-safe form))))
115              (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))              (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))
116              (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))))              ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form)))))
117          (if (not (plist-get rest :require))              )
118              `(defvar ,varname ,init ,doc)          `(progn
119            `(progn             (defvar ,varname ,init ,doc)
120               (defvar ,varname ,init ,doc)             (custom-autoload ',varname ,file))))
              (custom-add-to-group ,(plist-get rest :group)  
                                   ',varname 'custom-variable)  
              (custom-add-load ',varname  
                               ,(plist-get rest :require))))))  
121    
122       ;; nil here indicates that this is not a special autoload form.       ;; nil here indicates that this is not a special autoload form.
123       (t nil))))       (t nil))))
124    
125  ;;; Forms which have doc-strings which should be printed specially.  ;; Forms which have doc-strings which should be printed specially.
126  ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is  ;; A doc-string-elt property of ELT says that (nth ELT FORM) is
127  ;;; the doc-string in FORM.  ;; the doc-string in FORM.
128  ;;; Those properties are now set in lisp-mode.el.  ;; Those properties are now set in lisp-mode.el.
129    
130    
131  (defun autoload-trim-file-name (file)  (defun autoload-trim-file-name (file)
# Line 158  markers before we call `read'." Line 159  markers before we call `read'."
159          (goto-char (point-min))          (goto-char (point-min))
160          (read (current-buffer))))))          (read (current-buffer))))))
161    
162  ;; !! Requires OUTBUF to be bound !!  (defvar autoload-print-form-outbuf)
163    
164  (defun autoload-print-form (form)  (defun autoload-print-form (form)
165    "Print FORM such that make-docfile will find the docstrings."    "Print FORM such that `make-docfile' will find the docstrings.
166    The variable `autoload-print-form-outbuf' specifies the buffer to
167    put the output in."
168    (cond    (cond
169     ;; If the form is a sequence, recurse.     ;; If the form is a sequence, recurse.
170     ((eq (car form) 'progn) (mapcar 'autoload-print-form (cdr form)))     ((eq (car form) 'progn) (mapcar 'autoload-print-form (cdr form)))
171     ;; Symbols at the toplevel are meaningless.     ;; Symbols at the toplevel are meaningless.
172     ((symbolp form) nil)     ((symbolp form) nil)
173     (t     (t
174      (let ((doc-string-elt (get (car-safe form) 'doc-string-elt)))      (let ((doc-string-elt (get (car-safe form) 'doc-string-elt))
175              (outbuf autoload-print-form-outbuf))
176        (if (and doc-string-elt (stringp (nth doc-string-elt form)))        (if (and doc-string-elt (stringp (nth doc-string-elt form)))
177            ;; We need to hack the printing because the            ;; We need to hack the printing because the
178            ;; doc-string must be printed specially for            ;; doc-string must be printed specially for
# Line 178  markers before we call `read'." Line 183  markers before we call `read'."
183              (princ "\n(" outbuf)              (princ "\n(" outbuf)
184              (let ((print-escape-newlines t)              (let ((print-escape-newlines t)
185                    (print-escape-nonascii t))                    (print-escape-nonascii t))
186                (mapcar (lambda (elt)                (dolist (elt form)
187                          (prin1 elt outbuf)                  (prin1 elt outbuf)
188                          (princ " " outbuf))                  (princ " " outbuf)))
                       form))  
189              (princ "\"\\\n" outbuf)              (princ "\"\\\n" outbuf)
190              (let ((begin (with-current-buffer outbuf (point))))              (let ((begin (with-current-buffer outbuf (point))))
191                (princ (substring (prin1-to-string (car elt)) 1)                (princ (substring (prin1-to-string (car elt)) 1)
# Line 191  markers before we call `read'." Line 195  markers before we call `read'."
195                ;; the doc string.                ;; the doc string.
196                (with-current-buffer outbuf                (with-current-buffer outbuf
197                  (save-excursion                  (save-excursion
198                    (while (search-backward "\n(" begin t)                    (while (re-search-backward "\n[[(]" begin t)
199                      (forward-char 1)                      (forward-char 1)
200                      (insert "\\"))))                      (insert "\\"))))
201                (if (null (cdr elt))                (if (null (cdr elt))
# Line 218  markers before we call `read'." Line 222  markers before we call `read'."
222               ";; no-update-autoloads: t\n"               ";; no-update-autoloads: t\n"
223               ";; End:\n"               ";; End:\n"
224               ";;; " (file-name-nondirectory file)               ";;; " (file-name-nondirectory file)
225               "ends here\n")               " ends here\n")
226       nil file))       nil file))
227    file)    file)
228    
# Line 252  are used." Line 256  are used."
256    (let ((outbuf (current-buffer))    (let ((outbuf (current-buffer))
257          (autoloads-done '())          (autoloads-done '())
258          (load-name (let ((name (file-name-nondirectory file)))          (load-name (let ((name (file-name-nondirectory file)))
259                       (if (string-match "\\.elc?$" name)                       (if (string-match "\\.elc?\\(\\.\\|$\\)" name)
260                           (substring name 0 (match-beginning 0))                           (substring name 0 (match-beginning 0))
261                         name)))                         name)))
262          (print-length nil)          (print-length nil)
# Line 312  are used." Line 316  are used."
316                                (setq autoloads-done (cons (nth 1 form)                                (setq autoloads-done (cons (nth 1 form)
317                                                           autoloads-done))                                                           autoloads-done))
318                              (setq autoload form))                              (setq autoload form))
319                            (autoload-print-form autoload))                            (let ((autoload-print-form-outbuf outbuf))
320                                        (autoload-print-form autoload)))
321    
322                        ;; Copy the rest of the line to the output.                        ;; Copy the rest of the line to the output.
323                        (princ (buffer-substring                        (princ (buffer-substring
324                                (progn                                (progn
# Line 355  are used." Line 360  are used."
360  Return FILE if there was no autoload cookie in it."  Return FILE if there was no autoload cookie in it."
361    (interactive "fUpdate autoloads for file: ")    (interactive "fUpdate autoloads for file: ")
362    (let ((load-name (let ((name (file-name-nondirectory file)))    (let ((load-name (let ((name (file-name-nondirectory file)))
363                       (if (string-match "\\.elc?$" name)                       (if (string-match "\\.elc?\\(\\.\\|$\\)" name)
364                           (substring name 0 (match-beginning 0))                           (substring name 0 (match-beginning 0))
365                         name)))                         name)))
366          (found nil)          (found nil)
# Line 475  Autoload section for %s is up to date." Line 480  Autoload section for %s is up to date."
480  Update loaddefs.el with all the current autoloads from DIRS, and no old ones.  Update loaddefs.el with all the current autoloads from DIRS, and no old ones.
481  This uses `update-file-autoloads' (which see) do its work."  This uses `update-file-autoloads' (which see) do its work."
482    (interactive "DUpdate autoloads from directory: ")    (interactive "DUpdate autoloads from directory: ")
483    (let* ((files (apply 'nconc    (let* ((files-re (let ((tmp nil))
484                         (dolist (suf load-suffixes
485                                      (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))
486                           (unless (string-match "\\.elc" suf) (push suf tmp)))))
487             (files (apply 'nconc
488                         (mapcar (lambda (dir)                         (mapcar (lambda (dir)
489                                   (directory-files (expand-file-name dir)                                   (directory-files (expand-file-name dir)
490                                                    ;; FIXME: add .gz etc...                                                    t files-re))
                                                   t "^[^=.].*\\.el\\'"))  
491                                 dirs)))                                 dirs)))
492           (this-time (current-time))           (this-time (current-time))
493           (no-autoloads nil)             ;files with no autoload cookies.           (no-autoloads nil)             ;files with no autoload cookies.
# Line 529  This uses `update-file-autoloads' (which Line 537  This uses `update-file-autoloads' (which
537              (append no-autoloads              (append no-autoloads
538                      (delq nil (mapcar 'update-file-autoloads files))))                      (delq nil (mapcar 'update-file-autoloads files))))
539        (when no-autoloads        (when no-autoloads
540            ;; Sort them for better readability.
541            (setq no-autoloads (sort no-autoloads 'string<))
542          ;; Add the `no-autoloads' section.          ;; Add the `no-autoloads' section.
543          (goto-char (point-max))          (goto-char (point-max))
544          (search-backward "\f" nil t)          (search-backward "\f" nil t)

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.87.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26