diff options
| author | Karl Heuer | 1998-04-13 06:56:24 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-04-13 06:56:24 +0000 |
| commit | 05f6170c27059a082e99d5714680d8ec370861b9 (patch) | |
| tree | 4c2e7b208b938290f394fb5e350e635616cd284b | |
| parent | 7dbce55e8ffa07795e32d4c0acc5c59817ab1b59 (diff) | |
| download | emacs-05f6170c27059a082e99d5714680d8ec370861b9.tar.gz emacs-05f6170c27059a082e99d5714680d8ec370861b9.zip | |
(describe-function-1): New function.
(describe-function): Use describe-function-1.
(describe-key): Likewise.
| -rw-r--r-- | lisp/help.el | 136 |
1 files changed, 70 insertions, 66 deletions
diff --git a/lisp/help.el b/lisp/help.el index 56f62f7b1fc..6d2ae57b08d 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -331,13 +331,8 @@ If FUNCTION is nil, applies `message' to it, thus printing it." | |||
| 331 | (princ " at that spot")) | 331 | (princ " at that spot")) |
| 332 | (princ " runs the command ") | 332 | (princ " runs the command ") |
| 333 | (prin1 defn) | 333 | (prin1 defn) |
| 334 | (princ "\n") | 334 | (princ "\n which is ") |
| 335 | (let ((doc (documentation defn))) | 335 | (describe-function-1 defn nil) |
| 336 | (if doc | ||
| 337 | (progn (terpri) | ||
| 338 | (princ doc) | ||
| 339 | (help-setup-xref (cons #'describe-key key) (interactive-p))) | ||
| 340 | (princ "not documented"))) | ||
| 341 | (print-help-return-message))))))) | 336 | (print-help-return-message))))))) |
| 342 | 337 | ||
| 343 | (defun describe-mode () | 338 | (defun describe-mode () |
| @@ -579,65 +574,7 @@ C-w Display information on absence of warranty for GNU Emacs." | |||
| 579 | ;; Use " is " instead of a colon so that | 574 | ;; Use " is " instead of a colon so that |
| 580 | ;; it is easier to get out the function name using forward-sexp. | 575 | ;; it is easier to get out the function name using forward-sexp. |
| 581 | (princ " is ") | 576 | (princ " is ") |
| 582 | (let* ((def (symbol-function function)) | 577 | (describe-function-1 function nil) |
| 583 | file-name | ||
| 584 | (beg (if (commandp def) "an interactive " "a "))) | ||
| 585 | (princ (cond ((or (stringp def) | ||
| 586 | (vectorp def)) | ||
| 587 | "a keyboard macro") | ||
| 588 | ((subrp def) | ||
| 589 | (concat beg "built-in function")) | ||
| 590 | ((byte-code-function-p def) | ||
| 591 | (concat beg "compiled Lisp function")) | ||
| 592 | ((symbolp def) | ||
| 593 | (format "alias for `%s'" def)) | ||
| 594 | ((eq (car-safe def) 'lambda) | ||
| 595 | (concat beg "Lisp function")) | ||
| 596 | ((eq (car-safe def) 'macro) | ||
| 597 | "a Lisp macro") | ||
| 598 | ((eq (car-safe def) 'mocklisp) | ||
| 599 | "a mocklisp function") | ||
| 600 | ((eq (car-safe def) 'autoload) | ||
| 601 | (setq file-name (nth 1 def)) | ||
| 602 | (format "%s autoloaded Lisp %s" | ||
| 603 | (if (commandp def) "an interactive" "an") | ||
| 604 | (if (nth 4 def) "macro" "function") | ||
| 605 | )) | ||
| 606 | (t ""))) | ||
| 607 | (or file-name | ||
| 608 | (setq file-name (describe-function-find-file function))) | ||
| 609 | (if file-name | ||
| 610 | (progn | ||
| 611 | (princ " in `") | ||
| 612 | ;; We used to add .el to the file name, | ||
| 613 | ;; but that's completely wrong when the user used load-file. | ||
| 614 | (princ file-name) | ||
| 615 | (princ "'"))) | ||
| 616 | (princ ".") | ||
| 617 | (terpri) | ||
| 618 | (let* ((inner-function (if (and (listp def) 'macro) | ||
| 619 | (cdr def) | ||
| 620 | def)) | ||
| 621 | (arglist (cond ((byte-code-function-p inner-function) | ||
| 622 | (car (append inner-function nil))) | ||
| 623 | ((eq (car-safe inner-function) 'lambda) | ||
| 624 | (nth 1 inner-function)) | ||
| 625 | (t t)))) | ||
| 626 | (if (listp arglist) | ||
| 627 | (progn | ||
| 628 | (princ (cons function | ||
| 629 | (mapcar (lambda (arg) | ||
| 630 | (if (memq arg '(&optional &rest)) | ||
| 631 | arg | ||
| 632 | (intern (upcase (symbol-name arg))))) | ||
| 633 | arglist))) | ||
| 634 | (terpri)))) | ||
| 635 | (let ((doc (documentation function))) | ||
| 636 | (if doc | ||
| 637 | (progn (terpri) | ||
| 638 | (princ doc) | ||
| 639 | (help-setup-xref (cons #'describe-function function) (interactive-p))) | ||
| 640 | (princ "not documented")))) | ||
| 641 | (print-help-return-message) | 578 | (print-help-return-message) |
| 642 | (save-excursion | 579 | (save-excursion |
| 643 | (set-buffer standard-output) | 580 | (set-buffer standard-output) |
| @@ -645,6 +582,73 @@ C-w Display information on absence of warranty for GNU Emacs." | |||
| 645 | (buffer-string))) | 582 | (buffer-string))) |
| 646 | (message "You didn't specify a function"))) | 583 | (message "You didn't specify a function"))) |
| 647 | 584 | ||
| 585 | (defun describe-function-1 (function parens) | ||
| 586 | (let* ((def (symbol-function function)) | ||
| 587 | file-name string need-close | ||
| 588 | (beg (if (commandp def) "an interactive " "a "))) | ||
| 589 | (setq string | ||
| 590 | (cond ((or (stringp def) | ||
| 591 | (vectorp def)) | ||
| 592 | "a keyboard macro") | ||
| 593 | ((subrp def) | ||
| 594 | (concat beg "built-in function")) | ||
| 595 | ((byte-code-function-p def) | ||
| 596 | (concat beg "compiled Lisp function")) | ||
| 597 | ((symbolp def) | ||
| 598 | (format "alias for `%s'" def)) | ||
| 599 | ((eq (car-safe def) 'lambda) | ||
| 600 | (concat beg "Lisp function")) | ||
| 601 | ((eq (car-safe def) 'macro) | ||
| 602 | "a Lisp macro") | ||
| 603 | ((eq (car-safe def) 'mocklisp) | ||
| 604 | "a mocklisp function") | ||
| 605 | ((eq (car-safe def) 'autoload) | ||
| 606 | (setq file-name (nth 1 def)) | ||
| 607 | (format "%s autoloaded Lisp %s" | ||
| 608 | (if (commandp def) "an interactive" "an") | ||
| 609 | (if (nth 4 def) "macro" "function") | ||
| 610 | )) | ||
| 611 | (t ""))) | ||
| 612 | (when (and parens (not (equal string ""))) | ||
| 613 | (setq need-close t) | ||
| 614 | (princ "(")) | ||
| 615 | (princ string) | ||
| 616 | (or file-name | ||
| 617 | (setq file-name (describe-function-find-file function))) | ||
| 618 | (if file-name | ||
| 619 | (progn | ||
| 620 | (princ " in `") | ||
| 621 | ;; We used to add .el to the file name, | ||
| 622 | ;; but that's completely wrong when the user used load-file. | ||
| 623 | (princ file-name) | ||
| 624 | (princ "'"))) | ||
| 625 | (if need-close (princ ")")) | ||
| 626 | (princ ".") | ||
| 627 | (terpri) | ||
| 628 | (let* ((inner-function (if (and (listp def) 'macro) | ||
| 629 | (cdr def) | ||
| 630 | def)) | ||
| 631 | (arglist (cond ((byte-code-function-p inner-function) | ||
| 632 | (car (append inner-function nil))) | ||
| 633 | ((eq (car-safe inner-function) 'lambda) | ||
| 634 | (nth 1 inner-function)) | ||
| 635 | (t t)))) | ||
| 636 | (if (listp arglist) | ||
| 637 | (progn | ||
| 638 | (princ (cons function | ||
| 639 | (mapcar (lambda (arg) | ||
| 640 | (if (memq arg '(&optional &rest)) | ||
| 641 | arg | ||
| 642 | (intern (upcase (symbol-name arg))))) | ||
| 643 | arglist))) | ||
| 644 | (terpri)))) | ||
| 645 | (let ((doc (documentation function))) | ||
| 646 | (if doc | ||
| 647 | (progn (terpri) | ||
| 648 | (princ doc) | ||
| 649 | (help-setup-xref (cons #'describe-function function) (interactive-p))) | ||
| 650 | (princ "not documented"))))) | ||
| 651 | |||
| 648 | ;; We return 0 if we can't find a variable to return. | 652 | ;; We return 0 if we can't find a variable to return. |
| 649 | (defun variable-at-point () | 653 | (defun variable-at-point () |
| 650 | (condition-case () | 654 | (condition-case () |