diff options
| author | Gerd Moellmann | 2000-04-26 17:32:20 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-04-26 17:32:20 +0000 |
| commit | 2e48ba1817cc8fa07cc3ea57535d854bdd349fdc (patch) | |
| tree | 789fdaae14a79ddab5c92e0d1b2598f377c95d52 | |
| parent | 23c0fb21e745ac28ec24695bdf7fef723f5f86ad (diff) | |
| download | emacs-2e48ba1817cc8fa07cc3ea57535d854bdd349fdc.tar.gz emacs-2e48ba1817cc8fa07cc3ea57535d854bdd349fdc.zip | |
(help-xref-on-pp): New function.
(describe-variable): Use it to display xrefs in a symbol's value.
| -rw-r--r-- | lisp/help.el | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/lisp/help.el b/lisp/help.el index 12ef3ab81e2..fed3dd7f691 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -751,6 +751,29 @@ Return 0 if there is no such symbol." | |||
| 751 | (set-syntax-table stab))) | 751 | (set-syntax-table stab))) |
| 752 | (error 0))) | 752 | (error 0))) |
| 753 | 753 | ||
| 754 | (defun help-xref-on-pp (from to) | ||
| 755 | "Add xrefs for symbols in `pp's output between FROM and TO." | ||
| 756 | (let ((ost (syntax-table))) | ||
| 757 | (unwind-protect | ||
| 758 | (save-excursion | ||
| 759 | (save-restriction | ||
| 760 | (set-syntax-table emacs-lisp-mode-syntax-table) | ||
| 761 | (narrow-to-region from to) | ||
| 762 | (goto-char (point-min)) | ||
| 763 | (while (not (eobp)) | ||
| 764 | (cond | ||
| 765 | ((looking-at "\"") (forward-sexp 1)) | ||
| 766 | ((looking-at "#<") (search-forward ">" nil 'move)) | ||
| 767 | ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)") | ||
| 768 | (let* ((sym (intern-soft | ||
| 769 | (buffer-substring (match-beginning 1) (match-end 1)))) | ||
| 770 | (fn (cond ((fboundp sym) #'describe-function) | ||
| 771 | ((and sym (boundp sym)) #'describe-variable)))) | ||
| 772 | (when fn (help-xref-button 1 fn sym))) | ||
| 773 | (goto-char (match-end 1))) | ||
| 774 | (t (forward-char 1)))))) | ||
| 775 | (set-syntax-table ost)))) | ||
| 776 | |||
| 754 | (defun describe-variable (variable) | 777 | (defun describe-variable (variable) |
| 755 | "Display the full documentation of VARIABLE (a symbol). | 778 | "Display the full documentation of VARIABLE (a symbol). |
| 756 | Returns the documentation as a string, also." | 779 | Returns the documentation as a string, also." |
| @@ -772,20 +795,27 @@ Returns the documentation as a string, also." | |||
| 772 | (if (not (boundp variable)) | 795 | (if (not (boundp variable)) |
| 773 | (progn | 796 | (progn |
| 774 | (princ " is void") | 797 | (princ " is void") |
| 775 | (terpri) | ||
| 776 | (setq valvoid t)) | 798 | (setq valvoid t)) |
| 777 | (princ "'s value is ") | 799 | (let ((val (symbol-value variable))) |
| 778 | (terpri) | 800 | (with-current-buffer standard-output |
| 779 | (pp (symbol-value variable)) | 801 | (princ "'s value is ") |
| 780 | (terpri)) | 802 | (terpri) |
| 803 | (let ((from (point))) | ||
| 804 | (pp val) | ||
| 805 | (help-xref-on-pp from (point)))))) | ||
| 806 | (terpri) | ||
| 781 | (if (local-variable-p variable) | 807 | (if (local-variable-p variable) |
| 782 | (progn | 808 | (progn |
| 783 | (princ (format "Local in buffer %s; " (buffer-name))) | 809 | (princ (format "Local in buffer %s; " (buffer-name))) |
| 784 | (if (not (default-boundp variable)) | 810 | (if (not (default-boundp variable)) |
| 785 | (princ "globally void") | 811 | (princ "globally void") |
| 786 | (princ "global value is ") | 812 | (let ((val (default-value variable))) |
| 787 | (terpri) | 813 | (with-current-buffer standard-output |
| 788 | (pp (default-value variable))) | 814 | (princ "global value is ") |
| 815 | (terpri) | ||
| 816 | (let ((from (point))) | ||
| 817 | (pp val) | ||
| 818 | (help-xref-on-pp from (point)))))) | ||
| 789 | (terpri))) | 819 | (terpri))) |
| 790 | (terpri) | 820 | (terpri) |
| 791 | (save-current-buffer | 821 | (save-current-buffer |