diff options
| -rw-r--r-- | lisp/help.el | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/lisp/help.el b/lisp/help.el index 75fc64d7fa2..227e844959e 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -107,8 +107,10 @@ | |||
| 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 |
| @@ -287,9 +289,8 @@ If FUNCTION is nil, applies `message' to it, thus printing it." | |||
| 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)) |
| @@ -1039,6 +1040,9 @@ items for help buffer \"back\" buttons is cleared." | |||
| 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 | ||
| @@ -1154,7 +1158,7 @@ that." | |||
| 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)) |
| @@ -1245,16 +1249,16 @@ help buffer." | |||
| 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." |
| @@ -1286,11 +1290,13 @@ For the cross-reference format, see `help-make-xrefs'." | |||
| 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 () |