Commit 4c45295b authored by Karl Heuer's avatar Karl Heuer
Browse files

(help-setup-xref): Change all callers to

use (function args...) instead of (function . arg).  Doc fix.
(help-follow): Put (point) at front of elts of help-xref-stack.
(help-xref-stack): Elt format now (POSITION FUNCTION ARGS).
(help-xref-stack-item): Doc fix.
(help-xref-go-back): Assume new format for help-xref-stack.
(help-follow): Look for prop on previous char if next char has none.
Avoid error at beginning or end of buffer.
(describe-bindings): New optional arg BUFFER.
Use help-setup-xref.
parent 70cf9f08
...@@ -122,11 +122,14 @@ ...@@ -122,11 +122,14 @@
(defvar help-xref-stack nil (defvar help-xref-stack nil
"A stack of ways by which to return to help buffers after following xrefs. "A stack of ways by which to return to help buffers after following xrefs.
Used by `help-follow' and `help-xref-go-back'.") Used by `help-follow' and `help-xref-go-back'.
An element looks like (POSITION FUNCTION ARGS...).
To use the element, do (apply FUNCTION ARGS) then (goto-char POSITION).")
(put 'help-xref-stack 'permanent-local t) (put 'help-xref-stack 'permanent-local t)
(defvar help-xref-stack-item nil (defvar help-xref-stack-item nil
"An item for `help-follow' in this buffer to push onto `help-xref-stack'.") "An item for `help-follow' in this buffer to push onto `help-xref-stack'.
The format is (FUNCTION ARGS...).")
(put 'help-xref-stack-item 'permanent-local t) (put 'help-xref-stack-item 'permanent-local t)
(setq-default help-xref-stack nil help-xref-stack-item nil) (setq-default help-xref-stack nil help-xref-stack-item nil)
...@@ -377,7 +380,7 @@ followed by the major mode, which is described on the last page.\n\f\n")) ...@@ -377,7 +380,7 @@ followed by the major mode, which is described on the last page.\n\f\n"))
(princ mode-name) (princ mode-name)
(princ " mode:\n") (princ " mode:\n")
(princ (documentation major-mode)) (princ (documentation major-mode))
(help-setup-xref (cons #'help-xref-mode (current-buffer)) (interactive-p)) (help-setup-xref (list #'help-xref-mode (current-buffer)) (interactive-p))
(print-help-return-message))) (print-help-return-message)))
;; So keyboard macro definitions are documented correctly ;; So keyboard macro definitions are documented correctly
...@@ -658,7 +661,7 @@ C-w Display information on absence of warranty for GNU Emacs." ...@@ -658,7 +661,7 @@ C-w Display information on absence of warranty for GNU Emacs."
(if doc (if doc
(progn (terpri) (progn (terpri)
(princ doc) (princ doc)
(help-setup-xref (cons #'describe-function function) (interactive-p))) (help-setup-xref (list #'describe-function function) (interactive-p)))
(princ "not documented"))))) (princ "not documented")))))
;; We return 0 if we can't find a variable to return. ;; We return 0 if we can't find a variable to return.
...@@ -732,7 +735,7 @@ Returns the documentation as a string, also." ...@@ -732,7 +735,7 @@ Returns the documentation as a string, also."
(terpri) (terpri)
(let ((doc (documentation-property variable 'variable-documentation))) (let ((doc (documentation-property variable 'variable-documentation)))
(princ (or doc "not documented as a variable."))) (princ (or doc "not documented as a variable.")))
(help-setup-xref (cons #'describe-variable variable) (interactive-p)) (help-setup-xref (list #'describe-variable variable) (interactive-p))
;; Make a link to customize if this variable can be customized. ;; Make a link to customize if this variable can be customized.
(if (or (get variable 'custom-type) (if (or (get variable 'custom-type)
...@@ -756,17 +759,21 @@ Returns the documentation as a string, also." ...@@ -756,17 +759,21 @@ Returns the documentation as a string, also."
(buffer-string)))) (buffer-string))))
(message "You did not specify a variable"))) (message "You did not specify a variable")))
(defun describe-bindings (&optional prefix) (defun describe-bindings (&optional prefix buffer)
"Show a list of all defined keys, and their definitions. "Show a list of all defined keys, and their definitions.
We put that list in a buffer, and display the buffer. We put that list in a buffer, and display the buffer.
The optional argument PREFIX, if non-nil, should be a key sequence; The optional argument PREFIX, if non-nil, should be a key sequence;
then we display only bindings that start with that prefix." then we display only bindings that start with that prefix.
The optional argument BUFFER specifies which buffer's bindings
to display (default, the current buffer)."
(interactive "P") (interactive "P")
(describe-bindings-internal nil prefix) (or buffer (setq buffer (current-buffer)))
(with-current-buffer buffer
(describe-bindings-internal nil prefix))
(with-current-buffer "*Help*" (with-current-buffer "*Help*"
(setq help-xref-stack nil (help-setup-xref (list #'describe-bindings prefix buffer)
help-xref-stack-item nil))) (interactive-p))))
(defun where-is (definition &optional insert) (defun where-is (definition &optional insert)
"Print message listing key sequences that invoke specified command. "Print message listing key sequences that invoke specified command.
...@@ -889,7 +896,7 @@ distinguish references to variables, functions and symbols.") ...@@ -889,7 +896,7 @@ distinguish references to variables, functions and symbols.")
(defun help-setup-xref (item interactive-p) (defun help-setup-xref (item interactive-p)
"Invoked from commands using the \"*Help*\" buffer to install some xref info. "Invoked from commands using the \"*Help*\" buffer to install some xref info.
ITEM is a (function . args) pair appropriate for recreating the help ITEM is a (FUNCTION . ARGS) pair appropriate for recreating the help
buffer after following a reference. INTERACTIVE-P is non-nil if the buffer after following a reference. INTERACTIVE-P is non-nil if the
calling command was invoked interactively. In this case the stack of calling command was invoked interactively. In this case the stack of
items for help buffer \"back\" buttons is cleared." items for help buffer \"back\" buttons is cleared."
...@@ -1032,7 +1039,7 @@ help buffer." ...@@ -1032,7 +1039,7 @@ help buffer."
(goto-char (point-max)) (goto-char (point-max))
(insert "\n\n" fdoc)) (insert "\n\n" fdoc))
(goto-char (point-min)) (goto-char (point-min))
(help-setup-xref (cons #'help-xref-interned symbol) nil)) (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."
...@@ -1055,17 +1062,17 @@ help buffer." ...@@ -1055,17 +1062,17 @@ help buffer."
(defun help-xref-go-back (buffer) (defun help-xref-go-back (buffer)
"Go back to the previous help buffer text using info on `help-xref-stack'." "Go back to the previous help buffer text using info on `help-xref-stack'."
(interactive) (interactive)
(let (item method args) (let (item position method args)
(with-current-buffer buffer (with-current-buffer buffer
(when help-xref-stack (when help-xref-stack
(setq help-xref-stack (cdr help-xref-stack)) ; due to help-follow (setq help-xref-stack (cdr help-xref-stack)) ; due to help-follow
(setq item (car help-xref-stack) (setq item (car help-xref-stack)
method (car item) position (car item)
args (cdr item)) method (cadr item)
args (cddr item))
(setq help-xref-stack (cdr help-xref-stack)))) (setq help-xref-stack (cdr help-xref-stack))))
(if (listp args)
(apply method args) (apply method args)
(funcall method args)))) (goto-char position)))
(defun help-go-back () (defun help-go-back ()
(interactive) (interactive)
...@@ -1076,10 +1083,14 @@ help buffer." ...@@ -1076,10 +1083,14 @@ help buffer."
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 (get-text-property 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))))
(method (car help-data)) (method (car help-data))
(args (cdr help-data))) (args (cdr help-data)))
(setq help-xref-stack (cons help-xref-stack-item help-xref-stack)) (setq help-xref-stack (cons (cons (point) help-xref-stack-item)
help-xref-stack))
(setq help-xref-stack-item nil) (setq help-xref-stack-item nil)
(when help-data (when help-data
;; There is a reference at point. Follow it. ;; There is a reference at point. Follow it.
......
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