Mercurial > emacs
comparison lisp/help.el @ 28718:74b19c6efdd1
(help-xref-on-pp): New function.
(describe-variable): Use it to display xrefs in a symbol's value.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 26 Apr 2000 17:32:20 +0000 |
parents | 1d7862b7e02d |
children | 2a88fcce2568 |
comparison
equal
deleted
inserted
replaced
28717:228d0bc8e997 | 28718:74b19c6efdd1 |
---|---|
749 (or (and (symbolp obj) (boundp obj) obj) | 749 (or (and (symbolp obj) (boundp obj) obj) |
750 0))) | 750 0))) |
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." |
757 (interactive | 780 (interactive |
758 (let ((v (variable-at-point)) | 781 (let ((v (variable-at-point)) |
770 (with-output-to-temp-buffer "*Help*" | 793 (with-output-to-temp-buffer "*Help*" |
771 (prin1 variable) | 794 (prin1 variable) |
772 (if (not (boundp variable)) | 795 (if (not (boundp variable)) |
773 (progn | 796 (progn |
774 (princ " is void") | 797 (princ " is void") |
798 (setq valvoid t)) | |
799 (let ((val (symbol-value variable))) | |
800 (with-current-buffer standard-output | |
801 (princ "'s value is ") | |
775 (terpri) | 802 (terpri) |
776 (setq valvoid t)) | 803 (let ((from (point))) |
777 (princ "'s value is ") | 804 (pp val) |
778 (terpri) | 805 (help-xref-on-pp from (point)))))) |
779 (pp (symbol-value variable)) | 806 (terpri) |
780 (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 |
792 (set-buffer standard-output) | 822 (set-buffer standard-output) |
793 (if (> (count-lines (point-min) (point-max)) 10) | 823 (if (> (count-lines (point-min) (point-max)) 10) |