# HG changeset patch # User Stefan Monnier # Date 939831255 0 # Node ID 6613b383566670a1cb0f57e15f1f07f9098f9c99 # Parent 11f91800bec3a47e9d42632b5c39aa0023c2ec12 (help-xref-interned): make it also work on variable-only and function-only symbols. (help-make-xrefs): take advantage of the new `help-xref-interned'. (help-follow): if the point under mouse is not highlighted, try `help-xref-interned' on the pointed-to symbol anyway. diff -r 11f91800bec3 -r 6613b3835666 lisp/ChangeLog --- a/lisp/ChangeLog Wed Oct 13 14:48:57 1999 +0000 +++ b/lisp/ChangeLog Wed Oct 13 16:14:15 1999 +0000 @@ -1,5 +1,11 @@ 1999-10-13 Stefan Monnier + * help.el (help-xref-interned): make it also work on variable-only and + function-only symbols. + (help-make-xrefs): take advantage of the new `help-xref-interned'. + (help-follow): if the point under mouse is not highlighted, try + `help-xref-interned' on the pointed-to symbol anyway. + * info.el (Info-on-current-buffer): new entry point. (Info-find-node): split into two for Info-on-current-buffer to hook into it. diff -r 11f91800bec3 -r 6613b3835666 lisp/help.el --- a/lisp/help.el Wed Oct 13 14:48:57 1999 +0000 +++ b/lisp/help.el Wed Oct 13 16:14:15 1999 +0000 @@ -1034,14 +1034,10 @@ (and (fboundp sym) ; similarly (help-xref-button 6 #'describe-function sym))) ((match-string 5)) ; nothing for symbol - ((and (boundp sym) (fboundp sym)) + ((or (boundp sym) (fboundp sym)) ;; We can't intuit whether to use the ;; variable or function doc -- supply both. - (help-xref-button 6 #'help-xref-interned sym)) - ((boundp sym) - (help-xref-button 6 #'describe-variable sym)) - ((fboundp sym) - (help-xref-button 6 #'describe-function sym))))))) + (help-xref-button 6 #'help-xref-interned sym))))))) ;; An obvious case of a key substitution: (save-excursion (while (re-search-forward @@ -1121,15 +1117,17 @@ Both variable and function documentation are extracted into a single help buffer." - (let ((fdoc (describe-function symbol))) - (describe-variable symbol) - ;; We now have a help buffer on the variable. Insert the function - ;; text before it. - (with-current-buffer "*Help*" - (goto-char (point-min)) - (let ((inhibit-read-only t)) - (insert fdoc "\n\n" (symbol-name symbol) " is also a variable.\n\n")) - (help-setup-xref (list #'help-xref-interned symbol) nil)))) + (let ((fdoc (when (fboundp symbol) (describe-function symbol)))) + (when (or (boundp symbol) (not fdoc)) + (describe-variable symbol) + ;; We now have a help buffer on the variable. Insert the function + ;; text before it. + (when fdoc + (with-current-buffer "*Help*" + (goto-char (point-min)) + (let ((inhibit-read-only t)) + (insert fdoc "\n\n" (symbol-name symbol) " is also a variable.\n\n")) + (help-setup-xref (list #'help-xref-interned symbol) nil)))))) (defun help-xref-mode (buffer) "Do a `describe-mode' for the specified BUFFER." @@ -1167,21 +1165,32 @@ (interactive) (help-follow (1- (point-max)))) -(defun help-follow (&optional pos) +(defun help-follow (pos) "Follow cross-reference at POS, defaulting to point. For the cross-reference format, see `help-make-xrefs'." (interactive "d") - (let* ((help-data (or (and (not (= pos (point-max))) - (get-text-property pos 'help-xref)) - (and (not (= pos (point-min))) - (get-text-property (1- pos) 'help-xref)))) + (let* ((help-data + (or (and (not (= pos (point-max))) + (get-text-property pos 'help-xref)) + (and (not (= pos (point-min))) + (get-text-property (1- pos) 'help-xref)) + ;; check if the symbol under point is a function or variable + (let ((sym + (intern + (save-excursion + (goto-char pos) (skip-syntax-backward "w_") + (buffer-substring (point) + (progn (skip-syntax-forward "w_") + (point))))))) + (when (or (boundp sym) (fboundp sym)) + (list #'help-xref-interned sym))))) (method (car help-data)) (args (cdr help-data))) - (setq help-xref-stack (cons (cons (point) help-xref-stack-item) - help-xref-stack)) - (setq help-xref-stack-item nil) (when help-data + (setq help-xref-stack (cons (cons (point) help-xref-stack-item) + help-xref-stack)) + (setq help-xref-stack-item nil) ;; There is a reference at point. Follow it. (apply method args))))