Commit accd1266 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(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.
parent 4fceda3c
1999-10-13 Stefan Monnier <monnier@cs.yale.edu> 1999-10-13 Stefan Monnier <monnier@cs.yale.edu>
* 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.el (Info-on-current-buffer): new entry point.
(Info-find-node): split into two for Info-on-current-buffer to (Info-find-node): split into two for Info-on-current-buffer to
hook into it. hook into it.
......
...@@ -1034,14 +1034,10 @@ that." ...@@ -1034,14 +1034,10 @@ that."
(and (fboundp sym) ; similarly (and (fboundp sym) ; similarly
(help-xref-button 6 #'describe-function sym))) (help-xref-button 6 #'describe-function sym)))
((match-string 5)) ; nothing for symbol ((match-string 5)) ; nothing for symbol
((and (boundp sym) (fboundp sym)) ((or (boundp sym) (fboundp sym))
;; We can't intuit whether to use the ;; We can't intuit whether to use the
;; variable or function doc -- supply both. ;; variable or function doc -- supply both.
(help-xref-button 6 #'help-xref-interned sym)) (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)))))))
;; An obvious case of a key substitution: ;; An obvious case of a key substitution:
(save-excursion (save-excursion
(while (re-search-forward (while (re-search-forward
...@@ -1121,15 +1117,17 @@ See `help-make-xrefs'." ...@@ -1121,15 +1117,17 @@ See `help-make-xrefs'."
Both variable and function documentation are extracted into a single Both variable and function documentation are extracted into a single
help buffer." help buffer."
(let ((fdoc (describe-function symbol))) (let ((fdoc (when (fboundp symbol) (describe-function symbol))))
(describe-variable symbol) (when (or (boundp symbol) (not fdoc))
;; We now have a help buffer on the variable. Insert the function (describe-variable symbol)
;; text before it. ;; We now have a help buffer on the variable. Insert the function
(with-current-buffer "*Help*" ;; text before it.
(goto-char (point-min)) (when fdoc
(let ((inhibit-read-only t)) (with-current-buffer "*Help*"
(insert fdoc "\n\n" (symbol-name symbol) " is also a variable.\n\n")) (goto-char (point-min))
(help-setup-xref (list #'help-xref-interned symbol) nil)))) (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) (defun help-xref-mode (buffer)
"Do a `describe-mode' for the specified BUFFER." "Do a `describe-mode' for the specified BUFFER."
...@@ -1167,21 +1165,32 @@ help buffer." ...@@ -1167,21 +1165,32 @@ help buffer."
(interactive) (interactive)
(help-follow (1- (point-max)))) (help-follow (1- (point-max))))
(defun help-follow (&optional pos) (defun help-follow (pos)
"Follow cross-reference at POS, defaulting to point. "Follow cross-reference at POS, defaulting to point.
For the cross-reference format, see `help-make-xrefs'." For the cross-reference format, see `help-make-xrefs'."
(interactive "d") (interactive "d")
(let* ((help-data (or (and (not (= pos (point-max))) (let* ((help-data
(get-text-property pos 'help-xref)) (or (and (not (= pos (point-max)))
(and (not (= pos (point-min))) (get-text-property pos 'help-xref))
(get-text-property (1- 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)) (method (car help-data))
(args (cdr 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 (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. ;; There is a reference at point. Follow it.
(apply method args)))) (apply method args))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment