;;; help-mode.el --- `help-mode' used by *Help* buffers
-;; Copyright (C) 1985-1986, 1993-1994, 1998-2013 Free Software
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2015 Free Software
;; Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: help, internal
;; Package: emacs
(set-keymap-parent map (make-composed-keymap button-buffer-map
special-mode-map))
(define-key map [mouse-2] 'help-follow-mouse)
+ (define-key map "l" 'help-go-back)
+ (define-key map "r" 'help-go-forward)
(define-key map "\C-c\C-b" 'help-go-back)
(define-key map "\C-c\C-f" 'help-go-forward)
(define-key map [XF86Back] 'help-go-back)
(define-button-type 'help-function-def
:supertype 'help-xref
- 'help-function (lambda (fun file)
+ 'help-function (lambda (fun file &optional type)
(require 'find-func)
(when (eq file 'C-source)
(setq file
;; Don't use find-function-noselect because it follows
;; aliases (which fails for built-in functions).
(let ((location
- (find-function-search-for-symbol fun nil file)))
+ (find-function-search-for-symbol fun type file)))
(pop-to-buffer (car location))
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find function's definition"))
-(define-button-type 'help-function-cmacro
+(define-button-type 'help-function-cmacro ; FIXME: Obsolete since 24.4.
:supertype 'help-xref
'help-function (lambda (fun file)
(setq file (locate-library file t))
(pop-to-buffer (find-file-noselect file))
(goto-char (point-min))
(if (re-search-forward
- (format "^[ \t]*(define-compiler-macro[ \t]+%s"
+ (format "^[ \t]*(\\(cl-\\)?define-compiler-macro[ \t]+%s"
(regexp-quote (symbol-name fun))) nil t)
(forward-line 0)
(message "Unable to find location in file")))
(define-button-type 'help-dir-local-var-def
:supertype 'help-xref
- 'help-function (lambda (var &optional file)
+ 'help-function (lambda (_var &optional file)
;; FIXME: this should go to the point where the
;; local variable was defined.
(find-file file))
;;;###autoload
(defun help-mode-finish ()
- (when (eq major-mode 'help-mode)
+ (when (derived-mode-p 'help-mode)
(setq buffer-read-only t)
- (save-excursion
- (goto-char (point-min))
- (let ((inhibit-read-only t))
- (when (re-search-forward "^This [^[:space:]]+ is advised.$" nil t)
- (put-text-property (match-beginning 0)
- (match-end 0)
- 'face 'font-lock-warning-face))))
-
(help-make-xrefs (current-buffer))))
\f
;; Grokking cross-reference information in doc strings and
(defconst help-xref-symbol-regexp
(purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|" ; Link to var
- "\\(function\\|command\\)\\|" ; Link to function
+ "\\(function\\|command\\|call\\)\\|" ; Link to function
"\\(face\\)\\|" ; Link to face
"\\(symbol\\|program\\|property\\)\\|" ; Don't link
"\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
(while
(and (not (eobp))
;; Stop at a pair of blank lines.
- (not (looking-at "\n\\s-*\n")))
+ (not (looking-at-p "\n\\s-*\n")))
;; Skip a single blank line.
(and (eolp) (forward-line))
(end-of-line)
(save-restriction
(narrow-to-region from to)
(goto-char (point-min))
- (condition-case nil
- (while (not (eobp))
- (cond
- ((looking-at "\"") (forward-sexp 1))
- ((looking-at "#<") (search-forward ">" nil 'move))
- ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)")
- (let* ((sym (intern-soft (match-string 1)))
- (type (cond ((fboundp sym) 'help-function)
- ((or (memq sym '(t nil))
- (keywordp sym))
- nil)
- ((and sym
- (or (boundp sym)
- (get sym
- 'variable-documentation)))
- 'help-variable))))
- (when type (help-xref-button 1 type sym)))
- (goto-char (match-end 1)))
- (t (forward-char 1))))
- (error nil)))))))
+ (ignore-errors
+ (while (not (eobp))
+ (cond
+ ((looking-at-p "\"") (forward-sexp 1))
+ ((looking-at-p "#<") (search-forward ">" nil 'move))
+ ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)")
+ (let* ((sym (intern-soft (match-string 1)))
+ (type (cond ((fboundp sym) 'help-function)
+ ((or (memq sym '(t nil))
+ (keywordp sym))
+ nil)
+ ((and sym
+ (or (boundp sym)
+ (get sym
+ 'variable-documentation)))
+ 'help-variable))))
+ (when type (help-xref-button 1 type sym)))
+ (goto-char (match-end 1)))
+ (t (forward-char 1))))))))))
\f
;; Additional functions for (re-)creating types of help buffers.
-(defun help-xref-interned (symbol)
+
+;;;###autoload
+(defun help-xref-interned (symbol &optional buffer frame)
"Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
Both variable, function and face documentation are extracted into a single
-help buffer."
+help buffer. If SYMBOL is a variable, include buffer-local value for optional
+BUFFER or FRAME."
(with-current-buffer (help-buffer)
;; Push the previous item on the stack before clobbering the output buffer.
(help-setup-xref nil nil)
(get symbol 'variable-documentation))
;; Don't record the current entry in the stack.
(setq help-xref-stack-item nil)
- (describe-variable symbol))))
+ (describe-variable symbol buffer frame))))
(cond
(sdoc
;; We now have a help buffer on the variable.
" is also a " "face." "\n\n" facedoc))
;; Don't record the `describe-function' item in the stack.
(setq help-xref-stack-item nil)
- (help-setup-xref (list #'help-xref-interned symbol) nil)))))))
+ (help-setup-xref (list #'help-xref-interned symbol) nil))))
+ (goto-char (point-min)))))
\f
;; Navigation/hyperlinking with xrefs
(interactive)
(if help-xref-stack
(help-xref-go-back (current-buffer))
- (error "No previous help buffer")))
+ (user-error "No previous help buffer")))
(defun help-go-forward ()
"Go back to next topic in this help buffer."
(interactive)
(if help-xref-forward-stack
(help-xref-go-forward (current-buffer))
- (error "No next help buffer")))
+ (user-error "No next help buffer")))
(defun help-do-xref (_pos function args)
"Call the help cross-reference function FUNCTION with args ARGS.
a proper [back] button."
;; There is a reference at point. Follow it.
(let ((help-xref-following t))
- (apply function args)))
+ (apply function (if (eq function 'info)
+ (append args (list (generate-new-buffer-name "*info*"))) args))))
;; The doc string is meant to explain what buttons do.
(defun help-follow-mouse ()
For the cross-reference format, see `help-make-xrefs'."
(interactive)
- (error "No cross-reference here"))
+ (user-error "No cross-reference here"))
(defun help-follow-symbol (&optional pos)
"In help buffer, show docs for symbol at POS, defaulting to point.