Mercurial > hg > xemacs-beta
comparison lisp/autoload.el @ 1048:edc95b5fe4cb
[xemacs-hg @ 2002-10-11 14:09:46 by james]
Make modules autoload only if the module exists. Fix a paths bug that caused
module-directory, site-module-directory, and module-load-path to be wrong.
author | james |
---|---|
date | Fri, 11 Oct 2002 14:10:03 +0000 |
parents | 25e260cb7994 |
children | c08a6fa181d1 |
comparison
equal
deleted
inserted
replaced
1047:c46be6682f03 | 1048:edc95b5fe4cb |
---|---|
270 'doc-string-elt))) | 270 'doc-string-elt))) |
271 (if autoload | 271 (if autoload |
272 (setq autoloads-done (cons (nth 1 form) | 272 (setq autoloads-done (cons (nth 1 form) |
273 autoloads-done)) | 273 autoloads-done)) |
274 (setq autoload form)) | 274 (setq autoload form)) |
275 (print-autoload autoload doc-string-elt outbuf)) | 275 (print-autoload autoload doc-string-elt outbuf "")) |
276 ;; Copy the rest of the line to the output. | 276 ;; Copy the rest of the line to the output. |
277 (let ((begin (point))) | 277 (let ((begin (point))) |
278 ;; (terpri outbuf) | 278 ;; (terpri outbuf) |
279 (cond ((looking-at "immediate\\s *$") ; XEmacs | 279 (cond ((looking-at "immediate\\s *$") ; XEmacs |
280 ;; This is here so that you can automatically | 280 ;; This is here so that you can automatically |
332 (or noninteractive ; XEmacs: only need one line in -batch mode. | 332 (or noninteractive ; XEmacs: only need one line in -batch mode. |
333 (message "Generating autoloads for %s...done" file)))) | 333 (message "Generating autoloads for %s...done" file)))) |
334 | 334 |
335 (defun* generate-c-file-autoloads-1 (file funlist) | 335 (defun* generate-c-file-autoloads-1 (file funlist) |
336 "Insert at point a loaddefs autoload section for the C file FILE. | 336 "Insert at point a loaddefs autoload section for the C file FILE. |
337 autoloads are generated for Defuns and defmacros in FILE | 337 autoloads are generated for defuns and defmacros in FILE |
338 marked by `generate-c-autoload-cookie' (which see). | 338 marked by `generate-c-autoload-cookie' (which see). |
339 If FILE is being visited in a buffer, the contents of the buffer | 339 If FILE is being visited in a buffer, the contents of the buffer |
340 are used." | 340 are used." |
341 (let ((outbuf (current-buffer)) | 341 (let ((outbuf (current-buffer)) |
342 (autoloads-done '()) | 342 (autoloads-done '()) |
380 (skip-chars-forward "^ \t\n\f") | 380 (skip-chars-forward "^ \t\n\f") |
381 (setq load-name (buffer-substring begin (point))))) | 381 (setq load-name (buffer-substring begin (point))))) |
382 (if funlist | 382 (if funlist |
383 (progn | 383 (progn |
384 (message "Generating autoloads for %s..." trim-name) | 384 (message "Generating autoloads for %s..." trim-name) |
385 (princ "(when (or\n" outbuf) | |
386 (princ (format | |
387 " (file-exists-p (expand-file-name \"%s.ell\" module-directory))\n" | |
388 load-name) outbuf) | |
389 (princ (format | |
390 " (file-exists-p (expand-file-name \"%s.dll\" module-directory))\n" | |
391 load-name) outbuf) | |
392 (princ (format | |
393 " (file-exists-p (expand-file-name \"%s.so\" module-directory)))\n" | |
394 load-name) outbuf) | |
385 (dolist (arg funlist) | 395 (dolist (arg funlist) |
386 (goto-char (point-min)) | 396 (goto-char (point-min)) |
387 (re-search-forward | 397 (re-search-forward |
388 (concat "DEFUN (\"" | 398 (concat "DEFUN (\"" |
389 (regexp-quote (symbol-name arg)) | 399 (regexp-quote (symbol-name arg)) |
390 "\"")) | 400 "\"")) |
391 (goto-char (match-beginning 0)) | 401 (goto-char (match-beginning 0)) |
392 (let ((autoload (make-c-autoload load-name))) | 402 (let ((autoload (make-c-autoload load-name))) |
393 (when autoload | 403 (when autoload |
394 (push (nth 1 (nth 1 autoload)) autoloads-done) | 404 (push (nth 1 (nth 1 autoload)) autoloads-done) |
395 (print-autoload autoload 3 outbuf))))) | 405 (print-autoload autoload 3 outbuf " ")))) |
406 (princ ")" outbuf)) | |
396 (goto-char (point-min)) | 407 (goto-char (point-min)) |
397 (let ((match | 408 (let ((match |
398 (search-forward generate-c-autoload-cookie nil t))) | 409 (search-forward generate-c-autoload-cookie nil t))) |
399 (unless match | 410 (unless match |
400 (message "No autoloads found in %s" trim-name) | 411 (message "No autoloads found in %s" trim-name) |
401 (return-from generate-c-file-autoloads-1)) | 412 (return-from generate-c-file-autoloads-1)) |
402 | 413 |
403 (message "Generating autoloads for %s..." trim-name) | 414 (message "Generating autoloads for %s..." trim-name) |
415 (princ "(when (or\n" outbuf) | |
416 (princ (format | |
417 " (file-exists-p (expand-file-name \"%s.ell\" module-directory))\n" | |
418 load-name) outbuf) | |
419 (princ (format | |
420 " (file-exists-p (expand-file-name \"%s.dll\" module-directory))\n" | |
421 load-name) outbuf) | |
422 (princ (format | |
423 " (file-exists-p (expand-file-name \"%s.so\" module-directory)))\n" | |
424 load-name) outbuf) | |
404 (while match | 425 (while match |
405 (forward-line 1) | 426 (forward-line 1) |
406 (let ((autoload (make-c-autoload load-name))) | 427 (let ((autoload (make-c-autoload load-name))) |
407 (when autoload | 428 (when autoload |
408 (push (nth 1 (nth 1 autoload)) autoloads-done) | 429 (push (nth 1 (nth 1 autoload)) autoloads-done) |
409 (print-autoload autoload 3 outbuf))) | 430 (print-autoload autoload 3 outbuf " "))) |
410 (setq match | 431 (setq match |
411 (search-forward generate-c-autoload-cookie nil t)) | 432 (search-forward generate-c-autoload-cookie nil t))) |
412 )))))) | 433 (princ ")" outbuf)))))) |
413 (unless visited | 434 (unless visited |
414 ;; We created this buffer, so we should kill it. | 435 ;; We created this buffer, so we should kill it. |
415 (kill-buffer (current-buffer))) | 436 (kill-buffer (current-buffer))) |
416 (set-buffer outbuf) | 437 (set-buffer outbuf) |
417 (setq output-end (point-marker)))) | 438 (setq output-end (point-marker)))) |
423 (goto-char output-end) | 444 (goto-char output-end) |
424 (insert generate-autoload-section-trailer) | 445 (insert generate-autoload-section-trailer) |
425 (or noninteractive ; XEmacs: only need one line in -batch mode. | 446 (or noninteractive ; XEmacs: only need one line in -batch mode. |
426 (message "Generating autoloads for %s...done" trim-name)))) | 447 (message "Generating autoloads for %s...done" trim-name)))) |
427 | 448 |
428 (defun print-autoload (autoload doc-string-elt outbuf) | 449 (defun print-autoload (autoload doc-string-elt outbuf margin) |
429 "Print an autoload form, handling special characters. | 450 "Print an autoload form, handling special characters. |
430 In particular, print docstrings with escapes inserted before left parentheses | 451 In particular, print docstrings with escapes inserted before left parentheses |
431 at the beginning of lines and ^L characters." | 452 at the beginning of lines and ^L characters." |
432 (if (and doc-string-elt (stringp (nth doc-string-elt autoload))) | 453 (if (and doc-string-elt (stringp (nth doc-string-elt autoload))) |
433 ;; We need to hack the printing because the doc-string must be | 454 ;; We need to hack the printing because the doc-string must be |
434 ;; printed specially for make-docfile (sigh). | 455 ;; printed specially for make-docfile (sigh). |
435 (let* ((p (nthcdr (1- doc-string-elt) autoload)) | 456 (let* ((p (nthcdr (1- doc-string-elt) autoload)) |
436 (elt (cdr p))) | 457 (elt (cdr p)) |
458 (start-string (format "\n%s(" margin))) | |
437 (setcdr p nil) | 459 (setcdr p nil) |
438 (princ "\n(" outbuf) | 460 (princ start-string outbuf) |
439 ;; XEmacs change: don't let ^^L's get into | 461 ;; XEmacs change: don't let ^^L's get into |
440 ;; the file or sorting is hard. | 462 ;; the file or sorting is hard. |
441 (let ((print-escape-newlines t) | 463 (let ((print-escape-newlines t) |
442 (p (save-excursion | 464 (p (save-excursion |
443 (set-buffer outbuf) | 465 (set-buffer outbuf) |
464 ;; Insert a backslash before each ( that appears at the beginning | 486 ;; Insert a backslash before each ( that appears at the beginning |
465 ;; of a line in the doc string. | 487 ;; of a line in the doc string. |
466 (save-excursion | 488 (save-excursion |
467 (set-buffer outbuf) | 489 (set-buffer outbuf) |
468 (save-excursion | 490 (save-excursion |
469 (while (search-backward "\n(" begin t) | 491 (while (search-backward start-string begin t) |
470 (forward-char 1) | 492 (forward-char 1) |
471 (insert "\\")))) | 493 (insert "\\")))) |
472 (if (null (cdr elt)) | 494 (if (null (cdr elt)) |
473 (princ ")" outbuf) | 495 (princ ")" outbuf) |
474 (princ " " outbuf) | 496 (princ " " outbuf) |
475 (princ (substring (prin1-to-string (cdr elt)) 1) outbuf)) | 497 (princ (substring (prin1-to-string (cdr elt)) 1) outbuf)) |
476 (terpri outbuf))) | 498 (terpri outbuf) |
499 (princ margin outbuf))) | |
477 ;; XEmacs change: another ^L hack | 500 ;; XEmacs change: another ^L hack |
478 (let ((p (save-excursion | 501 (let ((p (save-excursion |
479 (set-buffer outbuf) | 502 (set-buffer outbuf) |
480 (point))) | 503 (point))) |
481 (print-escape-newlines t) | 504 (print-escape-newlines t) |