aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier1999-10-13 16:14:15 +0000
committerStefan Monnier1999-10-13 16:14:15 +0000
commitaccd12667f307e6d60ab47d50ce9630c1d8a86e4 (patch)
tree49103b43808c8fb188a6df03393a6121b1d3bcfa
parent4fceda3c2f20650ecd87d879449a27a1540e37cf (diff)
downloademacs-accd12667f307e6d60ab47d50ce9630c1d8a86e4.tar.gz
emacs-accd12667f307e6d60ab47d50ce9630c1d8a86e4.zip
(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.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/help.el55
2 files changed, 38 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9573fb88510..604268b6ae6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,11 @@
11999-10-13 Stefan Monnier <monnier@cs.yale.edu> 11999-10-13 Stefan Monnier <monnier@cs.yale.edu>
2 2
3 * help.el (help-xref-interned): make it also work on variable-only and
4 function-only symbols.
5 (help-make-xrefs): take advantage of the new `help-xref-interned'.
6 (help-follow): if the point under mouse is not highlighted, try
7 `help-xref-interned' on the pointed-to symbol anyway.
8
3 * info.el (Info-on-current-buffer): new entry point. 9 * info.el (Info-on-current-buffer): new entry point.
4 (Info-find-node): split into two for Info-on-current-buffer to 10 (Info-find-node): split into two for Info-on-current-buffer to
5 hook into it. 11 hook into it.
diff --git a/lisp/help.el b/lisp/help.el
index f07708a9461..c9c1821c732 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1034,14 +1034,10 @@ that."
1034 (and (fboundp sym) ; similarly 1034 (and (fboundp sym) ; similarly
1035 (help-xref-button 6 #'describe-function sym))) 1035 (help-xref-button 6 #'describe-function sym)))
1036 ((match-string 5)) ; nothing for symbol 1036 ((match-string 5)) ; nothing for symbol
1037 ((and (boundp sym) (fboundp sym)) 1037 ((or (boundp sym) (fboundp sym))
1038 ;; We can't intuit whether to use the 1038 ;; We can't intuit whether to use the
1039 ;; variable or function doc -- supply both. 1039 ;; variable or function doc -- supply both.
1040 (help-xref-button 6 #'help-xref-interned sym)) 1040 (help-xref-button 6 #'help-xref-interned sym)))))))
1041 ((boundp sym)
1042 (help-xref-button 6 #'describe-variable sym))
1043 ((fboundp sym)
1044 (help-xref-button 6 #'describe-function sym)))))))
1045 ;; An obvious case of a key substitution: 1041 ;; An obvious case of a key substitution:
1046 (save-excursion 1042 (save-excursion
1047 (while (re-search-forward 1043 (while (re-search-forward
@@ -1121,15 +1117,17 @@ See `help-make-xrefs'."
1121 1117
1122Both variable and function documentation are extracted into a single 1118Both variable and function documentation are extracted into a single
1123help buffer." 1119help buffer."
1124 (let ((fdoc (describe-function symbol))) 1120 (let ((fdoc (when (fboundp symbol) (describe-function symbol))))
1125 (describe-variable symbol) 1121 (when (or (boundp symbol) (not fdoc))
1126 ;; We now have a help buffer on the variable. Insert the function 1122 (describe-variable symbol)
1127 ;; text before it. 1123 ;; We now have a help buffer on the variable. Insert the function
1128 (with-current-buffer "*Help*" 1124 ;; text before it.
1129 (goto-char (point-min)) 1125 (when fdoc
1130 (let ((inhibit-read-only t)) 1126 (with-current-buffer "*Help*"
1131 (insert fdoc "\n\n" (symbol-name symbol) " is also a variable.\n\n")) 1127 (goto-char (point-min))
1132 (help-setup-xref (list #'help-xref-interned symbol) nil)))) 1128 (let ((inhibit-read-only t))
1129 (insert fdoc "\n\n" (symbol-name symbol) " is also a variable.\n\n"))
1130 (help-setup-xref (list #'help-xref-interned symbol) nil))))))
1133 1131
1134(defun help-xref-mode (buffer) 1132(defun help-xref-mode (buffer)
1135 "Do a `describe-mode' for the specified BUFFER." 1133 "Do a `describe-mode' for the specified BUFFER."
@@ -1167,21 +1165,32 @@ help buffer."
1167 (interactive) 1165 (interactive)
1168 (help-follow (1- (point-max)))) 1166 (help-follow (1- (point-max))))
1169 1167
1170(defun help-follow (&optional pos) 1168(defun help-follow (pos)
1171 "Follow cross-reference at POS, defaulting to point. 1169 "Follow cross-reference at POS, defaulting to point.
1172 1170
1173For the cross-reference format, see `help-make-xrefs'." 1171For the cross-reference format, see `help-make-xrefs'."
1174 (interactive "d") 1172 (interactive "d")
1175 (let* ((help-data (or (and (not (= pos (point-max))) 1173 (let* ((help-data
1176 (get-text-property pos 'help-xref)) 1174 (or (and (not (= pos (point-max)))
1177 (and (not (= pos (point-min))) 1175 (get-text-property pos 'help-xref))
1178 (get-text-property (1- pos) 'help-xref)))) 1176 (and (not (= pos (point-min)))
1177 (get-text-property (1- pos) 'help-xref))
1178 ;; check if the symbol under point is a function or variable
1179 (let ((sym
1180 (intern
1181 (save-excursion
1182 (goto-char pos) (skip-syntax-backward "w_")
1183 (buffer-substring (point)
1184 (progn (skip-syntax-forward "w_")
1185 (point)))))))
1186 (when (or (boundp sym) (fboundp sym))
1187 (list #'help-xref-interned sym)))))
1179 (method (car help-data)) 1188 (method (car help-data))
1180 (args (cdr help-data))) 1189 (args (cdr help-data)))
1181 (setq help-xref-stack (cons (cons (point) help-xref-stack-item)
1182 help-xref-stack))
1183 (setq help-xref-stack-item nil)
1184 (when help-data 1190 (when help-data
1191 (setq help-xref-stack (cons (cons (point) help-xref-stack-item)
1192 help-xref-stack))
1193 (setq help-xref-stack-item nil)
1185 ;; There is a reference at point. Follow it. 1194 ;; There is a reference at point. Follow it.
1186 (apply method args)))) 1195 (apply method args))))
1187 1196