annotate lisp/help-mode.el @ 86401:1b6c59c0ce17

Add description in @direntry.
author Romain Francoise <romain@orebokech.com>
date Sat, 24 Nov 2007 14:53:15 +0000
parents 4077065d3026
children 107ccd98fa12 880960b70474
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; help-mode.el --- `help-mode' used by *Help* buffers
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64306
diff changeset
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 72063
diff changeset
4 ;; 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
5
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Maintainer: FSF
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
7 ;; Keywords: help, internal
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
8
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
10
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 78068
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
14 ;; any later version.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
15
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
20
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63657
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63657
diff changeset
24 ;; Boston, MA 02110-1301, USA.
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
25
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
27
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; Defines `help-mode', which is the mode used by *Help* buffers, and
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;; associated support machinery, such as adding hyperlinks, etc.,
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
30
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;;; Code:
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
32
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 (require 'button)
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
34 (require 'view)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
35
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 (defvar help-mode-map (make-sparse-keymap)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
37 "Keymap for help mode.")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
38
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 (set-keymap-parent help-mode-map button-buffer-map)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
41 (define-key help-mode-map [mouse-2] 'help-follow-mouse)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
42 (define-key help-mode-map "\C-c\C-b" 'help-go-back)
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
43 (define-key help-mode-map "\C-c\C-f" 'help-go-forward)
69587
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
44 (define-key help-mode-map "\C-c\C-c" 'help-follow-symbol)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; Documentation only, since we use minor-mode-overriding-map-alist.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
46 (define-key help-mode-map "\r" 'help-follow)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
47
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 (defvar help-xref-stack nil
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 "A stack of ways by which to return to help buffers after following xrefs.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 Used by `help-follow' and `help-xref-go-back'.
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
51 An element looks like (POSITION FUNCTION ARGS...).
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
52 To use the element, do (apply FUNCTION ARGS) then goto the point.")
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 (put 'help-xref-stack 'permanent-local t)
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
54 (make-variable-buffer-local 'help-xref-stack)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
55
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
56 (defvar help-xref-forward-stack nil
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
57 "The stack of used to navigate help forwards after using the back button.
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
58 Used by `help-follow' and `help-xref-go-forward'.
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
59 An element looks like (POSITION FUNCTION ARGS...).
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
60 To use the element, do (apply FUNCTION ARGS) then goto the point.")
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
61 (put 'help-xref-forward-stack 'permanent-local t)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
62 (make-variable-buffer-local 'help-xref-forward-stack)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
63
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 (defvar help-xref-stack-item nil
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 "An item for `help-follow' in this buffer to push onto `help-xref-stack'.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 The format is (FUNCTION ARGS...).")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 (put 'help-xref-stack-item 'permanent-local t)
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
68 (make-variable-buffer-local 'help-xref-stack-item)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
69
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
70 (defvar help-xref-stack-forward-item nil
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
71 "An item for `help-go-back' to push onto `help-xref-forward-stack'.
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
72 The format is (FUNCTION ARGS...).")
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
73 (put 'help-xref-stack-forward-item 'permanent-local t)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
74 (make-variable-buffer-local 'help-xref-stack-forward-item)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
75
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 (setq-default help-xref-stack nil help-xref-stack-item nil)
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
77 (setq-default help-xref-forward-stack nil help-xref-forward-stack-item nil)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
78
41331
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
79 (defcustom help-mode-hook nil
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
80 "Hook run by `help-mode'."
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
81 :type 'hook
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
82 :group 'help)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
83
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 ;; Button types used by help
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
85
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
86 (define-button-type 'help-xref
59020
9916bd512da7 (help-xref): Add follow-link property.
Kim F. Storm <storm@cua.dk>
parents: 56579
diff changeset
87 'follow-link t
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
88 'action #'help-button-action)
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
89
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
90 (defun help-button-action (button)
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
91 "Call BUTTON's help function."
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
92 (help-do-xref (button-start button)
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
93 (button-get button 'help-function)
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
94 (button-get button 'help-args)))
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
95
41505
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
96 ;; These 6 calls to define-button-type were generated in a dolist
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
97 ;; loop, but that is bad because it means these button types don't
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
98 ;; have an easily found definition.
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
99
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
100 (define-button-type 'help-function
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
101 :supertype 'help-xref
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
102 'help-function 'describe-function
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
103 'help-echo (purecopy "mouse-2, RET: describe this function"))
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
104
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
105 (define-button-type 'help-variable
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
106 :supertype 'help-xref
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
107 'help-function 'describe-variable
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
108 'help-echo (purecopy "mouse-2, RET: describe this variable"))
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
109
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
110 (define-button-type 'help-face
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
111 :supertype 'help-xref
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
112 'help-function 'describe-face
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
113 'help-echo (purecopy "mouse-2, RET: describe this face"))
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
114
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
115 (define-button-type 'help-coding-system
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
116 :supertype 'help-xref
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
117 'help-function 'describe-coding-system
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
118 'help-echo (purecopy "mouse-2, RET: describe this coding system"))
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
119
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
120 (define-button-type 'help-input-method
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
121 :supertype 'help-xref
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
122 'help-function 'describe-input-method
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
123 'help-echo (purecopy "mouse-2, RET: describe this input method"))
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
124
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
125 (define-button-type 'help-character-set
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
126 :supertype 'help-xref
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
127 'help-function 'describe-character-set
77dd7bf4d860 (help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents: 41331
diff changeset
128 'help-echo (purecopy "mouse-2, RET: describe this character set"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
129
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 ;; make some more ideosyncratic button types
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
131
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 (define-button-type 'help-symbol
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
133 :supertype 'help-xref
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 'help-function #'help-xref-interned
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
135 'help-echo (purecopy "mouse-2, RET: describe this symbol"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
136
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 (define-button-type 'help-back
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
138 :supertype 'help-xref
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 'help-function #'help-xref-go-back
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
140 'help-echo (purecopy "mouse-2, RET: go back to previous help buffer"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
141
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
142 (define-button-type 'help-forward
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
143 :supertype 'help-xref
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
144 'help-function #'help-xref-go-forward
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
145 'help-echo (purecopy "mouse-2, RET: move forward to next help buffer"))
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
146
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 (define-button-type 'help-info
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
148 :supertype 'help-xref
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 'help-function #'info
66513
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
150 'help-echo (purecopy "mouse-2, RET: read this Info node"))
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
151
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
152 (define-button-type 'help-url
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
153 :supertype 'help-xref
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
154 'help-function #'browse-url
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
155 'help-echo (purecopy "mouse-2, RET: view this URL in a browser"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
156
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 (define-button-type 'help-customize-variable
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
158 :supertype 'help-xref
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 'help-function (lambda (v)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (customize-variable v))
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
161 'help-echo (purecopy "mouse-2, RET: customize variable"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
162
39800
8f2810b5b5e8 (help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents: 39787
diff changeset
163 (define-button-type 'help-customize-face
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
164 :supertype 'help-xref
39800
8f2810b5b5e8 (help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents: 39787
diff changeset
165 'help-function (lambda (v)
8f2810b5b5e8 (help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents: 39787
diff changeset
166 (customize-face v))
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
167 'help-echo (purecopy "mouse-2, RET: customize face"))
39800
8f2810b5b5e8 (help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents: 39787
diff changeset
168
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (define-button-type 'help-function-def
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
170 :supertype 'help-xref
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 'help-function (lambda (fun file)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 (require 'find-func)
55233
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
173 (when (eq file 'C-source)
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
174 (setq file
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
175 (help-C-file-name (indirect-function fun) 'fun)))
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
176 ;; Don't use find-function-noselect because it follows
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 ;; aliases (which fails for built-in functions).
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
178 (let ((location
55233
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
179 (find-function-search-for-symbol fun nil file)))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 (pop-to-buffer (car location))
72063
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
181 (if (cdr location)
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
182 (goto-char (cdr location))
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
183 (message "Unable to find location in file"))))
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
184 'help-echo (purecopy "mouse-2, RET: find function's definition"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
185
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
186 (define-button-type 'help-variable-def
40638
84e66cdcffc5 (help-xref): New button type.
Miles Bader <miles@gnu.org>
parents: 40191
diff changeset
187 :supertype 'help-xref
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 'help-function (lambda (var &optional file)
55233
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
189 (when (eq file 'C-source)
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
190 (setq file (help-C-file-name var 'var)))
038fab289258 (help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55010
diff changeset
191 (let ((location (find-variable-noselect var file)))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 (pop-to-buffer (car location))
72063
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
193 (if (cdr location)
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
194 (goto-char (cdr location))
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
195 (message "Unable to find location in file"))))
71801
5846e054fdf9 Add space for clarity.
Kim F. Storm <storm@cua.dk>
parents: 71522
diff changeset
196 'help-echo (purecopy "mouse-2, RET: find variable's definition"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
197
62387
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
198 (define-button-type 'help-face-def
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
199 :supertype 'help-xref
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
200 'help-function (lambda (fun file)
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
201 (require 'find-func)
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
202 ;; Don't use find-function-noselect because it follows
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
203 ;; aliases (which fails for built-in functions).
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
204 (let ((location
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
205 (find-function-search-for-symbol fun 'defface file)))
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
206 (pop-to-buffer (car location))
72063
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
207 (if (cdr location)
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
208 (goto-char (cdr location))
52eeda6a8959 (help-function-def, help-variable-def)
Nick Roberts <nickrob@snap.net.nz>
parents: 71850
diff changeset
209 (message "Unable to find location in file"))))
62387
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
210 'help-echo (purecopy "mouse-2, RET: find face's definition"))
c051115aeb95 (help-face-def): New button type.
Richard M. Stallman <rms@gnu.org>
parents: 60462
diff changeset
211
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
212
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
213 ;;;###autoload
41331
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
214 (defun help-mode ()
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
215 "Major mode for viewing help text and navigating references in it.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
216 Entry to this mode runs the normal hook `help-mode-hook'.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 Commands:
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
218 \\{help-mode-map}"
41331
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
219 (interactive)
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
220 (kill-all-local-variables)
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
221 (use-local-map help-mode-map)
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
222 (setq mode-name "Help")
8fa706b1026c (help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents: 40638
diff changeset
223 (setq major-mode 'help-mode)
86006
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
224
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
225 (view-mode)
86006
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
226 (set (make-local-variable 'view-no-disable-on-exit) t)
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
227 ;; With Emacs 22 `view-exit-action' could delete the selected window
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
228 ;; disregarding whether the help buffer was shown in that window at
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
229 ;; all. Since `view-exit-action' is called with the help buffer as
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
230 ;; argument it seems more appropriate to have it work on the buffer
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
231 ;; only and leave it to `view-mode-exit' to delete any associated
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
232 ;; window(s).
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
233 (setq view-exit-action
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
234 (lambda (buffer)
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
235 ;; Use `with-current-buffer' to make sure that `bury-buffer'
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
236 ;; also removes BUFFER from the selected window.
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
237 (with-current-buffer buffer
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
238 (bury-buffer))))
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
239
62729
40c5f688942a (help-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 62387
diff changeset
240 (run-mode-hooks 'help-mode-hook))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
241
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
242 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
243 (defun help-mode-setup ()
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
244 (help-mode)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
245 (setq buffer-read-only nil))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
246
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
247 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
248 (defun help-mode-finish ()
86006
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
249 (if (eq help-window t)
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
250 ;; If `help-window' is t, `view-return-to-alist' is handled by
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
251 ;; `with-help-window'. In this case set `help-window' to the
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
252 ;; selected window since now is the only moment where we can
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
253 ;; unambiguously identify it.
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
254 (setq help-window (selected-window))
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
255 (let ((entry (assq (selected-window) view-return-to-alist)))
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
256 (if entry
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
257 ;; When entering Help mode from the Help window,
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
258 ;; such as by following a link, preserve the same
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
259 ;; meaning for the q command.
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
260 ;; (setcdr entry (cons (selected-window) help-return-method))
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
261 nil
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
262 (setq view-return-to-alist
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
263 (cons (cons (selected-window) help-return-method)
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
264 view-return-to-alist)))))
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
265
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
266 (when (eq major-mode 'help-mode)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
267 ;; View mode's read-only status of existing *Help* buffer is lost
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
268 ;; by with-output-to-temp-buffer.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
269 (toggle-read-only 1)
55010
734c2a20e3ec (help-mode-finish): Set help-return-alist first
Richard M. Stallman <rms@gnu.org>
parents: 54781
diff changeset
270 (help-make-xrefs (current-buffer))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
271
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
272 ;; Grokking cross-reference information in doc strings and
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
273 ;; hyperlinking it.
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
274
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
275 ;; This may have some scope for extension and the same or something
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
276 ;; similar should be done for widget doc strings, which currently use
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
277 ;; another mechanism.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
278
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
279 (defvar help-back-label (purecopy "[back]")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
280 "Label to use by `help-make-xrefs' for the go-back reference.")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
281
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
282 (defvar help-forward-label (purecopy "[forward]")
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
283 "Label to use by `help-make-xrefs' for the go-forward reference.")
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
284
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
285 (defconst help-xref-symbol-regexp
69587
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
286 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|" ; Link to var
71522
d530d0a35e81 (help-xref-symbol-regexp): Add property as a keyword for ignoring links.
Nick Roberts <nickrob@snap.net.nz>
parents: 70326
diff changeset
287 "\\(function\\|command\\)\\|" ; Link to function
d530d0a35e81 (help-xref-symbol-regexp): Add property as a keyword for ignoring links.
Nick Roberts <nickrob@snap.net.nz>
parents: 70326
diff changeset
288 "\\(face\\)\\|" ; Link to face
d530d0a35e81 (help-xref-symbol-regexp): Add property as a keyword for ignoring links.
Nick Roberts <nickrob@snap.net.nz>
parents: 70326
diff changeset
289 "\\(symbol\\|program\\|property\\)\\|" ; Don't link
52876
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
290 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
291 "[ \t\n]+\\)?"
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
292 ;; Note starting with word-syntax character:
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
293 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'"))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
294 "Regexp matching doc string references to symbols.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
295
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
296 The words preceding the quoted symbol can be used in doc strings to
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
297 distinguish references to variables, functions and symbols.")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
298
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
299 (defvar help-xref-mule-regexp nil
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
300 "Regexp matching doc string references to MULE-related keywords.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
301
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
302 It is usually nil, and is temporarily bound to an appropriate regexp
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
303 when help commands related to multilingual environment (e.g.,
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
304 `describe-coding-system') are invoked.")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
305
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
306
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
307 (defconst help-xref-info-regexp
53455
0e3e62b0f4f2 (help-xref-info-regexp): Make hyperlinks to Info documentation if the
Luc Teirlinck <teirllm@auburn.edu>
parents: 52885
diff changeset
308 (purecopy "\\<[Ii]nfo[ \t\n]+\\(node\\|anchor\\)[ \t\n]+`\\([^']+\\)'")
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
309 "Regexp matching doc string references to an Info node.")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
310
66513
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
311 (defconst help-xref-url-regexp
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
312 (purecopy "\\<[Uu][Rr][Ll][ \t\n]+`\\([^']+\\)'")
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
313 "Regexp matching doc string references to a URL.")
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
314
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
315 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
316 (defun help-setup-xref (item interactive-p)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
317 "Invoked from commands using the \"*Help*\" buffer to install some xref info.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
318
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
319 ITEM is a (FUNCTION . ARGS) pair appropriate for recreating the help
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
320 buffer after following a reference. INTERACTIVE-P is non-nil if the
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
321 calling command was invoked interactively. In this case the stack of
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
322 items for help buffer \"back\" buttons is cleared.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
323
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
324 This should be called very early, before the output buffer is cleared,
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
325 because we want to record the \"previous\" position of point so we can
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
326 restore it properly when going back."
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
327 (with-current-buffer (help-buffer)
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
328 (when help-xref-stack-item
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
329 (push (cons (point) help-xref-stack-item) help-xref-stack)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
330 (setq help-xref-forward-stack nil))
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
331 (when interactive-p
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
332 (let ((tail (nthcdr 10 help-xref-stack)))
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
333 ;; Truncate the stack.
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
334 (if tail (setcdr tail nil))))
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
335 (setq help-xref-stack-item item)))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
336
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
337 (defvar help-xref-following nil
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
338 "Non-nil when following a help cross-reference.")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
339
86006
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
340 ;;;###autoload
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
341 (defun help-buffer ()
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
342 (buffer-name ;for with-output-to-temp-buffer
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
343 (if help-xref-following
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
344 (current-buffer)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
345 (get-buffer-create "*Help*"))))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
346
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
347 (defvar help-xref-override-view-map
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
348 (let ((map (make-sparse-keymap)))
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
349 (set-keymap-parent map view-mode-map)
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
350 (define-key map "\r" nil)
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
351 map)
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
352 "Replacement keymap for `view-mode' in help buffers.")
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
353
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
354 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
355 (defun help-make-xrefs (&optional buffer)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
356 "Parse and hyperlink documentation cross-references in the given BUFFER.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
357
45763
6499a200d5d5 (help-mode): Don't set `font-lock-defaults'.
Colin Walters <walters@gnu.org>
parents: 42680
diff changeset
358 Find cross-reference information in a buffer and activate such cross
6499a200d5d5 (help-mode): Don't set `font-lock-defaults'.
Colin Walters <walters@gnu.org>
parents: 42680
diff changeset
359 references for selection with `help-follow'. Cross-references have
6499a200d5d5 (help-mode): Don't set `font-lock-defaults'.
Colin Walters <walters@gnu.org>
parents: 42680
diff changeset
360 the canonical form `...' and the type of reference may be
6499a200d5d5 (help-mode): Don't set `font-lock-defaults'.
Colin Walters <walters@gnu.org>
parents: 42680
diff changeset
361 disambiguated by the preceding word(s) used in
52876
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
362 `help-xref-symbol-regexp'. Faces only get cross-referenced if
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
363 preceded or followed by the word `face'. Variables without
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
364 variable documentation do not get cross-referenced, unless
52878
80f69b7f19c1 (help-make-xrefs): Slight correction to previous change.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52876
diff changeset
365 preceded by the word `variable' or `option'.
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
366
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
367 If the variable `help-xref-mule-regexp' is non-nil, find also
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
368 cross-reference information related to multilingual environment
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
369 \(e.g., coding-systems). This variable is also used to disambiguate
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
370 the type of reference as the same way as `help-xref-symbol-regexp'.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
371
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
372 A special reference `back' is made to return back through a stack of
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
373 help buffers. Variable `help-back-label' specifies the text for
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
374 that."
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
375 (interactive "b")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
376 (save-excursion
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
377 (set-buffer (or buffer (current-buffer)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
378 (goto-char (point-min))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
379 ;; Skip the header-type info, though it might be useful to parse
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
380 ;; it at some stage (e.g. "function in `library'").
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
381 (forward-paragraph)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
382 (let ((old-modified (buffer-modified-p)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
383 (let ((stab (syntax-table))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
384 (case-fold-search t)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
385 (inhibit-read-only t))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
386 (set-syntax-table emacs-lisp-mode-syntax-table)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
387 ;; The following should probably be abstracted out.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
388 (unwind-protect
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
389 (progn
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
390 ;; Info references
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
391 (save-excursion
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
392 (while (re-search-forward help-xref-info-regexp nil t)
53455
0e3e62b0f4f2 (help-xref-info-regexp): Make hyperlinks to Info documentation if the
Luc Teirlinck <teirllm@auburn.edu>
parents: 52885
diff changeset
393 (let ((data (match-string 2)))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
394 (save-match-data
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
395 (unless (string-match "^([^)]+)" data)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
396 (setq data (concat "(emacs)" data))))
53455
0e3e62b0f4f2 (help-xref-info-regexp): Make hyperlinks to Info documentation if the
Luc Teirlinck <teirllm@auburn.edu>
parents: 52885
diff changeset
397 (help-xref-button 2 'help-info data))))
66513
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
398 ;; URLs
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
399 (save-excursion
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
400 (while (re-search-forward help-xref-url-regexp nil t)
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
401 (let ((data (match-string 1)))
bfd70a868157 (help-url): New button type. Calls browse-url.
Bill Wohler <wohler@newt.com>
parents: 64762
diff changeset
402 (help-xref-button 1 'help-url data))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
403 ;; Mule related keywords. Do this before trying
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
404 ;; `help-xref-symbol-regexp' because some of Mule
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
405 ;; keywords have variable or function definitions.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
406 (if help-xref-mule-regexp
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
407 (save-excursion
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
408 (while (re-search-forward help-xref-mule-regexp nil t)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
409 (let* ((data (match-string 7))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
410 (sym (intern-soft data)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
411 (cond
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
412 ((match-string 3) ; coding system
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
413 (and sym (coding-system-p sym)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
414 (help-xref-button 6 'help-coding-system sym)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
415 ((match-string 4) ; input method
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
416 (and (assoc data input-method-alist)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
417 (help-xref-button 7 'help-input-method data)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
418 ((or (match-string 5) (match-string 6)) ; charset
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
419 (and sym (charsetp sym)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
420 (help-xref-button 7 'help-character-set sym)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
421 ((assoc data input-method-alist)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
422 (help-xref-button 7 'help-character-set data))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
423 ((and sym (coding-system-p sym))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
424 (help-xref-button 7 'help-coding-system sym))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
425 ((and sym (charsetp sym))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
426 (help-xref-button 7 'help-character-set sym)))))))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
427 ;; Quoted symbols
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
428 (save-excursion
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
429 (while (re-search-forward help-xref-symbol-regexp nil t)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
430 (let* ((data (match-string 8))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
431 (sym (intern-soft data)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
432 (if sym
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
433 (cond
52876
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
434 ((match-string 3) ; `variable' &c
66874
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
435 (and (or (boundp sym) ; `variable' doesn't ensure
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
436 ; it's actually bound
66874
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
437 (get sym 'variable-documentation))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
438 (help-xref-button 8 'help-variable sym)))
52876
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
439 ((match-string 4) ; `function' &c
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
440 (and (fboundp sym) ; similarly
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
441 (help-xref-button 8 'help-function sym)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
442 ((match-string 5) ; `face'
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
443 (and (facep sym)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
444 (help-xref-button 8 'help-face sym)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
445 ((match-string 6)) ; nothing for `symbol'
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
446 ((match-string 7)
52876
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
447 ;;; this used:
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
448 ;;; #'(lambda (arg)
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
449 ;;; (let ((location
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
450 ;;; (find-function-noselect arg)))
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
451 ;;; (pop-to-buffer (car location))
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
452 ;;; (goto-char (cdr location))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
453 (help-xref-button 8 'help-function-def sym))
63657
06603f5724ed (help-make-xrefs): If a symbol representing a face name is not followed by the
Juanma Barranquero <lekktu@gmail.com>
parents: 62729
diff changeset
454 ((and
06603f5724ed (help-make-xrefs): If a symbol representing a face name is not followed by the
Juanma Barranquero <lekktu@gmail.com>
parents: 62729
diff changeset
455 (facep sym)
06603f5724ed (help-make-xrefs): If a symbol representing a face name is not followed by the
Juanma Barranquero <lekktu@gmail.com>
parents: 62729
diff changeset
456 (save-match-data (looking-at "[ \t\n]+face\\W")))
06603f5724ed (help-make-xrefs): If a symbol representing a face name is not followed by the
Juanma Barranquero <lekktu@gmail.com>
parents: 62729
diff changeset
457 (help-xref-button 8 'help-face sym))
66874
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
458 ((and (or (boundp sym)
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
459 (get sym 'variable-documentation))
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
460 (fboundp sym))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
461 ;; We can't intuit whether to use the
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
462 ;; variable or function doc -- supply both.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
463 (help-xref-button 8 'help-symbol sym))
52876
64833a41c107 (help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
464 ((and
66874
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
465 (or (boundp sym)
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
466 (get sym 'variable-documentation))
54717
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
467 (or
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
468 (documentation-property
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
469 sym 'variable-documentation)
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
470 (condition-case nil
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
471 (documentation-property
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
472 (indirect-variable sym)
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
473 'variable-documentation)
a0b481c8f7d5 (help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents: 53455
diff changeset
474 (cyclic-variable-indirection nil))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
475 (help-xref-button 8 'help-variable sym))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
476 ((fboundp sym)
52885
8221f516da37 (help-make-xrefs): Make sure that if a symbol is followed by the word
Luc Teirlinck <teirllm@auburn.edu>
parents: 52878
diff changeset
477 (help-xref-button 8 'help-function sym)))))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
478 ;; An obvious case of a key substitution:
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
479 (save-excursion
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
480 (while (re-search-forward
82334
081f1ab64053 (help-make-xrefs): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 82327
diff changeset
481 ;; Assume command name is only word and symbol
82327
b6f47ca099b7 (help-make-xrefs): Search for symbol constituents, rather than just `-'.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
482 ;; characters to get things like `use M-x foo->bar'.
82334
081f1ab64053 (help-make-xrefs): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 82327
diff changeset
483 ;; Command required to end with word constituent
081f1ab64053 (help-make-xrefs): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 82327
diff changeset
484 ;; to avoid `.' at end of a sentence.
081f1ab64053 (help-make-xrefs): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 82327
diff changeset
485 "\\<M-x\\s-+\\(\\sw\\(\\sw\\|\\s_\\)*\\sw\\)" nil t)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
486 (let ((sym (intern-soft (match-string 1))))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
487 (if (fboundp sym)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
488 (help-xref-button 1 'help-function sym)))))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
489 ;; Look for commands in whole keymap substitutions:
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
490 (save-excursion
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
491 ;; Make sure to find the first keymap.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
492 (goto-char (point-min))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
493 ;; Find a header and the column at which the command
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
494 ;; name will be found.
50684
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
495
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
496 ;; If the keymap substitution isn't the last thing in
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
497 ;; the doc string, and if there is anything on the
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
498 ;; same line after it, this code won't recognize the end of it.
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
499 (while (re-search-forward "^key +binding\n\\(-+ +\\)-+\n\n"
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
500 nil t)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
501 (let ((col (- (match-end 1) (match-beginning 1))))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
502 (while
50684
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
503 (and (not (eobp))
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
504 ;; Stop at a pair of blank lines.
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
505 (not (looking-at "\n\\s-*\n")))
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
506 ;; Skip a single blank line.
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
507 (and (eolp) (forward-line))
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
508 (end-of-line)
78068
5af810b51863 (help-make-xrefs): Skip spaces too when skipping tabs.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
509 (skip-chars-backward "^ \t\n")
50684
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
510 (if (and (>= (current-column) col)
82327
b6f47ca099b7 (help-make-xrefs): Search for symbol constituents, rather than just `-'.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
511 (looking-at "\\(\\sw\\|\\s_\\)+$"))
50684
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
512 (let ((sym (intern-soft (match-string 0))))
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
513 (if (fboundp sym)
21af30889a41 (help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents: 49690
diff changeset
514 (help-xref-button 0 'help-function sym))))
50691
e2879cfe85cf (help-make-xrefs): Remove extra paren.
John Paul Wallington <jpw@pobox.com>
parents: 50684
diff changeset
515 (forward-line))))))
e2879cfe85cf (help-make-xrefs): Remove extra paren.
John Paul Wallington <jpw@pobox.com>
parents: 50684
diff changeset
516 (set-syntax-table stab))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
517 ;; Delete extraneous newlines at the end of the docstring
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
518 (goto-char (point-max))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
519 (while (and (not (bobp)) (bolp))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
520 (delete-char -1))
54781
bdfa0aa8c425 (help-make-xrefs): Add a final newline to the *Help* buffer.
Juri Linkov <juri@jurta.org>
parents: 54748
diff changeset
521 (insert "\n")
81490
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
522 (when (or help-xref-stack help-xref-forward-stack)
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
523 (insert "\n"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
524 ;; Make a back-reference in this buffer if appropriate.
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
525 (when help-xref-stack
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
526 (help-insert-xref-button help-back-label 'help-back
81490
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
527 (current-buffer)))
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
528 ;; Make a forward-reference in this buffer if appropriate.
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
529 (when help-xref-forward-stack
81490
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
530 (when help-xref-stack
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
531 (insert "\t"))
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
532 (help-insert-xref-button help-forward-label 'help-forward
81490
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
533 (current-buffer)))
802dc93432c1 (help-make-xrefs): Adjust position of new forward
Martin Rudalics <rudalics@gmx.at>
parents: 81266
diff changeset
534 (when (or help-xref-stack help-xref-forward-stack)
54781
bdfa0aa8c425 (help-make-xrefs): Add a final newline to the *Help* buffer.
Juri Linkov <juri@jurta.org>
parents: 54748
diff changeset
535 (insert "\n")))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
536 ;; View mode steals RET from us.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
537 (set (make-local-variable 'minor-mode-overriding-map-alist)
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
538 (list (cons 'view-mode help-xref-override-view-map)))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
539 (set-buffer-modified-p old-modified))))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
540
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
541 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
542 (defun help-xref-button (match-number type &rest args)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
543 "Make a hyperlink for cross-reference text previously matched.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
544 MATCH-NUMBER is the subexpression of interest in the last matched
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
545 regexp. TYPE is the type of button to use. Any remaining arguments are
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
546 passed to the button's help-function when it is invoked.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
547 See `help-make-xrefs'."
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
548 ;; Don't mung properties we've added specially in some instances.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
549 (unless (button-at (match-beginning match-number))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
550 (make-text-button (match-beginning match-number)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
551 (match-end match-number)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
552 'type type 'help-args args)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
553
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
554 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
555 (defun help-insert-xref-button (string type &rest args)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
556 "Insert STRING and make a hyperlink from cross-reference text on it.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
557 TYPE is the type of button to use. Any remaining arguments are passed
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
558 to the button's help-function when it is invoked.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
559 See `help-make-xrefs'."
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
560 (unless (button-at (point))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
561 (insert-text-button string 'type type 'help-args args)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
562
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
563 ;;;###autoload
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
564 (defun help-xref-on-pp (from to)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
565 "Add xrefs for symbols in `pp's output between FROM and TO."
49690
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
566 (if (> (- to from) 5000) nil
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
567 (with-syntax-table emacs-lisp-mode-syntax-table
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
568 (save-excursion
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
569 (save-restriction
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
570 (narrow-to-region from to)
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
571 (goto-char (point-min))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
572 (condition-case nil
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
573 (while (not (eobp))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
574 (cond
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
575 ((looking-at "\"") (forward-sexp 1))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
576 ((looking-at "#<") (search-forward ">" nil 'move))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
577 ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)")
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
578 (let* ((sym (intern-soft (match-string 1)))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
579 (type (cond ((fboundp sym) 'help-function)
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
580 ((or (memq sym '(t nil))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
581 (keywordp sym))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
582 nil)
66874
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
583 ((and sym
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
584 (or (boundp sym)
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
585 (get sym
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
586 'variable-documentation)))
49690
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
587 'help-variable))))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
588 (when type (help-xref-button 1 type sym)))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
589 (goto-char (match-end 1)))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
590 (t (forward-char 1))))
e2f33e589249 (help-xref-on-pp): Only add xref if the text is less than 5K.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46437
diff changeset
591 (error nil)))))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
592
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
593
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
594 ;; Additional functions for (re-)creating types of help buffers.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
595 (defun help-xref-interned (symbol)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
596 "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
597 Both variable, function and face documentation are extracted into a single
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
598 help buffer."
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
599 (with-current-buffer (help-buffer)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
600 ;; Push the previous item on the stack before clobbering the output buffer.
64306
c7d6013c38b6 (help-xref-interned): Undo last mistaken change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64305
diff changeset
601 (help-setup-xref nil nil)
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
602 (let ((facedoc (when (facep symbol)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
603 ;; Don't record the current entry in the stack.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
604 (setq help-xref-stack-item nil)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
605 (describe-face symbol)))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
606 (fdoc (when (fboundp symbol)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
607 ;; Don't record the current entry in the stack.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
608 (setq help-xref-stack-item nil)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
609 (describe-function symbol)))
66874
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
610 (sdoc (when (or (boundp symbol)
2f22c8af038b (help-make-xrefs, help-xref-on-pp, help-xref-interned, help-follow):
Luc Teirlinck <teirllm@auburn.edu>
parents: 66513
diff changeset
611 (get symbol 'variable-documentation))
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
612 ;; Don't record the current entry in the stack.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
613 (setq help-xref-stack-item nil)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
614 (describe-variable symbol))))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
615 (cond
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
616 (sdoc
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
617 ;; We now have a help buffer on the variable.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
618 ;; Insert the function and face text before it.
42593
dbb64f2b3684 Fix indentation.
Richard M. Stallman <rms@gnu.org>
parents: 42334
diff changeset
619 (when (or fdoc facedoc)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
620 (goto-char (point-min))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
621 (let ((inhibit-read-only t))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
622 (when fdoc
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
623 (insert fdoc "\n\n")
42593
dbb64f2b3684 Fix indentation.
Richard M. Stallman <rms@gnu.org>
parents: 42334
diff changeset
624 (when facedoc
dbb64f2b3684 Fix indentation.
Richard M. Stallman <rms@gnu.org>
parents: 42334
diff changeset
625 (insert (make-string 30 ?-) "\n\n" (symbol-name symbol)
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
626 " is also a " "face." "\n\n")))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
627 (when facedoc
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
628 (insert facedoc "\n\n"))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
629 (insert (make-string 30 ?-) "\n\n" (symbol-name symbol)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
630 " is also a " "variable." "\n\n"))
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
631 ;; Don't record the `describe-variable' item in the stack.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
632 (setq help-xref-stack-item nil)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
633 (help-setup-xref (list #'help-xref-interned symbol) nil)))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
634 (fdoc
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
635 ;; We now have a help buffer on the function.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
636 ;; Insert face text before it.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
637 (when facedoc
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
638 (goto-char (point-max))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
639 (let ((inhibit-read-only t))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
640 (insert "\n\n" (make-string 30 ?-) "\n\n" (symbol-name symbol)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
641 " is also a " "face." "\n\n" facedoc))
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
642 ;; Don't record the `describe-function' item in the stack.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
643 (setq help-xref-stack-item nil)
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
644 (help-setup-xref (list #'help-xref-interned symbol) nil)))))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
645
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
646
46437
6987a52d9b98 (view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45767
diff changeset
647 ;; Navigation/hyperlinking with xrefs
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
648
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
649 (defun help-xref-go-back (buffer)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
650 "From BUFFER, go back to previous help buffer text using `help-xref-stack'."
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
651 (let (item position method args)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
652 (with-current-buffer buffer
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
653 (push (cons (point) help-xref-stack-item) help-xref-forward-stack)
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
654 (when help-xref-stack
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
655 (setq item (pop help-xref-stack)
39787
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
656 ;; Clear the current item so that it won't get pushed
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
657 ;; by the function we're about to call. TODO: We could also
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
658 ;; push it onto a "forward" stack and add a `forw' button.
b44e34df3fa2 (help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39727
diff changeset
659 help-xref-stack-item nil
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
660 position (car item)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
661 method (cadr item)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
662 args (cddr item))))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
663 (apply method args)
42680
3814cb15269e (help-xref-go-back): Restore POSITION in proper buffer and proper window.
Richard M. Stallman <rms@gnu.org>
parents: 42593
diff changeset
664 (with-current-buffer buffer
3814cb15269e (help-xref-go-back): Restore POSITION in proper buffer and proper window.
Richard M. Stallman <rms@gnu.org>
parents: 42593
diff changeset
665 (if (get-buffer-window buffer)
3814cb15269e (help-xref-go-back): Restore POSITION in proper buffer and proper window.
Richard M. Stallman <rms@gnu.org>
parents: 42593
diff changeset
666 (set-window-point (get-buffer-window buffer) position)
3814cb15269e (help-xref-go-back): Restore POSITION in proper buffer and proper window.
Richard M. Stallman <rms@gnu.org>
parents: 42593
diff changeset
667 (goto-char position)))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
668
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
669 (defun help-xref-go-forward (buffer)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
670 "From BUFFER, go forward to next help buffer."
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
671 (let (item position method args)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
672 (with-current-buffer buffer
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
673 (push (cons (point) help-xref-stack-item) help-xref-stack)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
674 (when help-xref-forward-stack
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
675 (setq item (pop help-xref-forward-stack)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
676 ;; Clear the current item so that it won't get pushed
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
677 ;; by the function we're about to call. TODO: We could also
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
678 ;; push it onto a "forward" stack and add a `forw' button.
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
679 help-xref-stack-item nil
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
680 position (car item)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
681 method (cadr item)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
682 args (cddr item))))
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
683 (apply method args)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
684 (with-current-buffer buffer
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
685 (if (get-buffer-window buffer)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
686 (set-window-point (get-buffer-window buffer) position)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
687 (goto-char position)))))
86006
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
688
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
689 (defun help-go-back ()
55679
839ccd7aaee0 (help-go-back): Don't depend on position of back button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55233
diff changeset
690 "Go back to previous topic in this help buffer."
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
691 (interactive)
55679
839ccd7aaee0 (help-go-back): Don't depend on position of back button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55233
diff changeset
692 (if help-xref-stack
839ccd7aaee0 (help-go-back): Don't depend on position of back button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55233
diff changeset
693 (help-xref-go-back (current-buffer))
56579
6a5acd0aae39 (help-go-back): Delete period from end of error message.
John Paul Wallington <jpw@pobox.com>
parents: 55679
diff changeset
694 (error "No previous help buffer")))
86006
4077065d3026 (help-mode): Set view-exit-action to bury the
Martin Rudalics <rudalics@gmx.at>
parents: 82334
diff changeset
695
81266
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
696 (defun help-go-forward ()
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
697 "Go back to next topic in this help buffer."
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
698 (interactive)
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
699 (if help-xref-forward-stack
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
700 (help-xref-go-forward (current-buffer))
3b6f2f7b68f2 (help-xref-forward-stack)
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
701 (error "No next help buffer")))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
702
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
703 (defun help-do-xref (pos function args)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
704 "Call the help cross-reference function FUNCTION with args ARGS.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
705 Things are set up properly so that the resulting help-buffer has
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
706 a proper [back] button."
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
707 ;; There is a reference at point. Follow it.
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
708 (let ((help-xref-following t))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
709 (apply function args)))
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
710
69587
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
711 ;; The doc string is meant to explain what buttons do.
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
712 (defun help-follow-mouse ()
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
713 "Follow the cross-reference that you click on."
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
714 (interactive)
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
715 (error "No cross-reference here"))
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
716
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
717 ;; The doc string is meant to explain what buttons do.
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
718 (defun help-follow ()
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
719 "Follow cross-reference at point.
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
720
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
721 For the cross-reference format, see `help-make-xrefs'."
69587
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
722 (interactive)
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
723 (error "No cross-reference here"))
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
724
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
725 (defun help-follow-symbol (&optional pos)
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
726 "In help buffer, show docs for symbol at POS, defaulting to point.
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
727 Show all docs for that symbol as either a variable, function or face."
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
728 (interactive "d")
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
729 (unless pos
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
730 (setq pos (point)))
69587
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
731 ;; check if the symbol under point is a function, variable or face
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
732 (let ((sym
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
733 (intern
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
734 (save-excursion
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
735 (goto-char pos) (skip-syntax-backward "w_")
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
736 (buffer-substring (point)
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
737 (progn (skip-syntax-forward "w_")
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
738 (point)))))))
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
739 (when (or (boundp sym)
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
740 (get sym 'variable-documentation)
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
741 (fboundp sym) (facep sym))
ddaea7e69d4f (help-follow-symbol): New function. Essentially identical to the old
Luc Teirlinck <teirllm@auburn.edu>
parents: 68651
diff changeset
742 (help-do-xref pos #'help-xref-interned (list sym)))))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
743
67854
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
744 (defun help-insert-string (string)
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
745 "Insert STRING to the help buffer and install xref info for it.
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
746 This function can be used to restore the old contents of the help buffer
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
747 when going back to the previous topic in the xref stack. It is needed
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
748 in case when it is impossible to recompute the old contents of the
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
749 help buffer by other means."
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
750 (setq help-xref-stack-item (list #'help-insert-string string))
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
751 (with-output-to-temp-buffer (help-buffer)
eb33196c14d7 (help-insert-string): New function. Save buffer
Nick Roberts <nickrob@snap.net.nz>
parents: 67697
diff changeset
752 (insert string)))
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
753
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
754 (provide 'help-mode)
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
755
64305
d533a2de8243 (help-xref-interned): Properly setup xref info.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64091
diff changeset
756 ;; arch-tag: 850954ae-3725-4cb4-8e91-0bf6d52d6b0b
39727
3806fe844742 New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff changeset
757 ;;; help-mode.el ends here