Mercurial > emacs
comparison lisp/help.el @ 28909:43d9eb93e1fb
(help-xref-stack): Doc fix.
(help-xref-following): New variable.
(help-make-xrefs): Use it.
(help-xref-go-back): Use position information from stack element.
(help-follow): Make position in stack element a pair. Use
help-xref-following.
author | Dave Love <fx@gnu.org> |
---|---|
date | Sun, 14 May 2000 15:48:45 +0000 |
parents | 354a826d7b20 |
children | 0a2323529cff |
comparison
equal
deleted
inserted
replaced
28908:7b7bdd8aaa74 | 28909:43d9eb93e1fb |
---|---|
105 (define-key help-mode-map "\r" 'help-follow) | 105 (define-key help-mode-map "\r" 'help-follow) |
106 | 106 |
107 (defvar help-xref-stack nil | 107 (defvar help-xref-stack nil |
108 "A stack of ways by which to return to help buffers after following xrefs. | 108 "A stack of ways by which to return to help buffers after following xrefs. |
109 Used by `help-follow' and `help-xref-go-back'. | 109 Used by `help-follow' and `help-xref-go-back'. |
110 An element looks like (POSITION FUNCTION ARGS...). | 110 An element looks like (POSITION FUNCTION ARGS...), where POSITION is |
111 To use the element, do (apply FUNCTION ARGS) then (goto-char POSITION).") | 111 `(POINT . BUFFER-NAME)'. |
112 To use the element, do (apply FUNCTION ARGS) then goto the point in | |
113 the named buffer.") | |
112 (put 'help-xref-stack 'permanent-local t) | 114 (put 'help-xref-stack 'permanent-local t) |
113 | 115 |
114 (defvar help-xref-stack-item nil | 116 (defvar help-xref-stack-item nil |
115 "An item for `help-follow' in this buffer to push onto `help-xref-stack'. | 117 "An item for `help-follow' in this buffer to push onto `help-xref-stack'. |
116 The format is (FUNCTION ARGS...).") | 118 The format is (FUNCTION ARGS...).") |
285 (window-start) (window-point))) | 287 (window-start) (window-point))) |
286 "Type \\[switch-to-buffer] RET to remove help window.")))) | 288 "Type \\[switch-to-buffer] RET to remove help window.")))) |
287 (funcall (or function 'message) | 289 (funcall (or function 'message) |
288 (concat | 290 (concat |
289 (if first-message | 291 (if first-message |
290 (substitute-command-keys first-message) | 292 (substitute-command-keys first-message)) |
291 "") | 293 (if first-message " ") |
292 (if first-message " " "") | |
293 ;; If the help buffer will go in a separate frame, | 294 ;; If the help buffer will go in a separate frame, |
294 ;; it's no use mentioning a command to scroll, so don't. | 295 ;; it's no use mentioning a command to scroll, so don't. |
295 (if (special-display-p (buffer-name standard-output)) | 296 (if (special-display-p (buffer-name standard-output)) |
296 nil | 297 nil |
297 (if (same-window-p (buffer-name standard-output)) | 298 (if (same-window-p (buffer-name standard-output)) |
1037 items for help buffer \"back\" buttons is cleared." | 1038 items for help buffer \"back\" buttons is cleared." |
1038 (if interactive-p | 1039 (if interactive-p |
1039 (setq help-xref-stack nil)) | 1040 (setq help-xref-stack nil)) |
1040 (setq help-xref-stack-item item)) | 1041 (setq help-xref-stack-item item)) |
1041 | 1042 |
1043 (defvar help-xref-following nil | |
1044 "Non-nil when following a help cross-reference.") | |
1045 | |
1042 (defun help-make-xrefs (&optional buffer) | 1046 (defun help-make-xrefs (&optional buffer) |
1043 "Parse and hyperlink documentation cross-references in the given BUFFER. | 1047 "Parse and hyperlink documentation cross-references in the given BUFFER. |
1044 | 1048 |
1045 Find cross-reference information in a buffer and, if | 1049 Find cross-reference information in a buffer and, if |
1046 `help-highlight-p' is non-nil, highlight it with face defined by | 1050 `help-highlight-p' is non-nil, highlight it with face defined by |
1152 0 #'describe-function sym | 1156 0 #'describe-function sym |
1153 "mouse-2, RET: describe this function")))) | 1157 "mouse-2, RET: describe this function")))) |
1154 (zerop (forward-line))))))))) | 1158 (zerop (forward-line))))))))) |
1155 (set-syntax-table stab)) | 1159 (set-syntax-table stab)) |
1156 ;; Make a back-reference in this buffer if appropriate. | 1160 ;; Make a back-reference in this buffer if appropriate. |
1157 (when help-xref-stack | 1161 (when (and help-xref-following help-xref-stack) |
1158 (goto-char (point-max)) | 1162 (goto-char (point-max)) |
1159 (save-excursion | 1163 (save-excursion |
1160 (insert "\n\n" help-back-label)) | 1164 (insert "\n\n" help-back-label)) |
1161 ;; Just to provide the match data: | 1165 ;; Just to provide the match data: |
1162 (looking-at (concat "\n\n\\(" (regexp-quote help-back-label) "\\)")) | 1166 (looking-at (concat "\n\n\\(" (regexp-quote help-back-label) "\\)")) |
1243 "From BUFFER, go back to previous help buffer text using `help-xref-stack'." | 1247 "From BUFFER, go back to previous help buffer text using `help-xref-stack'." |
1244 (let (item position method args) | 1248 (let (item position method args) |
1245 (with-current-buffer buffer | 1249 (with-current-buffer buffer |
1246 (when help-xref-stack | 1250 (when help-xref-stack |
1247 (setq help-xref-stack (cdr help-xref-stack)) ; due to help-follow | 1251 (setq help-xref-stack (cdr help-xref-stack)) ; due to help-follow |
1248 (setq item (car help-xref-stack) | 1252 (setq item (pop help-xref-stack) |
1249 position (car item) | 1253 position (car item) |
1250 method (cadr item) | 1254 method (cadr item) |
1251 args (cddr item)) | 1255 args (cddr item)))) |
1252 (setq help-xref-stack (cdr help-xref-stack)))) | |
1253 (apply method args) | 1256 (apply method args) |
1254 ;; We're not in the right buffer to do this, and we don't actually | 1257 ;; We assume that the buffer we just recreated has the saved name, |
1255 ;; know which we should be in. | 1258 ;; which might not always be true. |
1256 ;;(goto-char position) | 1259 (when (get-buffer (cdr position)) |
1257 )) | 1260 (with-current-buffer (cdr position) |
1261 (goto-char (car position)))))) | |
1258 | 1262 |
1259 (defun help-go-back () | 1263 (defun help-go-back () |
1260 "Invoke the [back] button (if any) in the Help mode buffer." | 1264 "Invoke the [back] button (if any) in the Help mode buffer." |
1261 (interactive) | 1265 (interactive) |
1262 (help-follow (1- (point-max)))) | 1266 (help-follow (1- (point-max)))) |
1284 (when (or (boundp sym) (fboundp sym)) | 1288 (when (or (boundp sym) (fboundp sym)) |
1285 (list #'help-xref-interned sym))))) | 1289 (list #'help-xref-interned sym))))) |
1286 (method (car help-data)) | 1290 (method (car help-data)) |
1287 (args (cdr help-data))) | 1291 (args (cdr help-data))) |
1288 (when help-data | 1292 (when help-data |
1289 (setq help-xref-stack (cons (cons (point) help-xref-stack-item) | 1293 (setq help-xref-stack (cons (cons (cons pos (buffer-name)) |
1294 help-xref-stack-item) | |
1290 help-xref-stack)) | 1295 help-xref-stack)) |
1291 (setq help-xref-stack-item nil) | 1296 (setq help-xref-stack-item nil) |
1292 ;; There is a reference at point. Follow it. | 1297 ;; There is a reference at point. Follow it. |
1293 (apply method args)))) | 1298 (let ((help-xref-following t)) |
1299 (apply method args))))) | |
1294 | 1300 |
1295 ;; For tabbing through buffer. | 1301 ;; For tabbing through buffer. |
1296 (defun help-next-ref () | 1302 (defun help-next-ref () |
1297 "Find the next help cross-reference in the buffer." | 1303 "Find the next help cross-reference in the buffer." |
1298 (interactive) | 1304 (interactive) |