Mercurial > emacs
annotate lisp/help-mode.el @ 61515:0d659f1010a4
*** empty log message ***
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Tue, 12 Apr 2005 23:40:00 +0000 |
parents | df46d87c0c2f |
children | c051115aeb95 29e773288013 |
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 |
54748
8143853620d8
(help-function-def, help-variable-def): Handle hyperrefs
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54717
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002, 2004 |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
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 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
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 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
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) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
43 (define-key help-mode-map "\C-c\C-c" 'help-follow) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
44 ;; 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
|
45 (define-key help-mode-map "\r" 'help-follow) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
46 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
47 (defvar help-xref-stack nil |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
48 "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
|
49 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
|
50 An element looks like (POSITION FUNCTION ARGS...). |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
51 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
|
52 (put 'help-xref-stack 'permanent-local t) |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
53 (make-variable-buffer-local 'help-xref-stack) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
54 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
55 (defvar help-xref-stack-item nil |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
56 "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
|
57 The format is (FUNCTION ARGS...).") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
58 (put 'help-xref-stack-item 'permanent-local t) |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
59 (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
|
60 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
61 (setq-default help-xref-stack nil help-xref-stack-item nil) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
62 |
41331
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
63 (defcustom help-mode-hook nil |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
64 "Hook run by `help-mode'." |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
65 :type 'hook |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
66 :group 'help) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
67 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
68 ;; Button types used by help |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
69 |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
70 (define-button-type 'help-xref |
59020
9916bd512da7
(help-xref): Add follow-link property.
Kim F. Storm <storm@cua.dk>
parents:
56579
diff
changeset
|
71 'follow-link t |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
72 'action #'help-button-action) |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
73 |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
74 (defun help-button-action (button) |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
75 "Call BUTTON's help function." |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
76 (help-do-xref (button-start button) |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
77 (button-get button 'help-function) |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
78 (button-get button 'help-args))) |
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
79 |
41505
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
80 ;; 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
|
81 ;; 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
|
82 ;; have an easily found definition. |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
83 |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
84 (define-button-type 'help-function |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
85 :supertype 'help-xref |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
86 'help-function 'describe-function |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
87 '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
|
88 |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
89 (define-button-type 'help-variable |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
90 :supertype 'help-xref |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
91 'help-function 'describe-variable |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
92 '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
|
93 |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
94 (define-button-type 'help-face |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
95 :supertype 'help-xref |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
96 'help-function 'describe-face |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
97 '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
|
98 |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
99 (define-button-type 'help-coding-system |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
100 :supertype 'help-xref |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
101 'help-function 'describe-coding-system |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
102 '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
|
103 |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
104 (define-button-type 'help-input-method |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
105 :supertype 'help-xref |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
106 'help-function 'describe-input-method |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
107 '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
|
108 |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
109 (define-button-type 'help-character-set |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
110 :supertype 'help-xref |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
111 'help-function 'describe-character-set |
77dd7bf4d860
(help-function, help-variable, help-face)
Richard M. Stallman <rms@gnu.org>
parents:
41331
diff
changeset
|
112 '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
|
113 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
114 ;; make some more ideosyncratic button types |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
115 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
116 (define-button-type 'help-symbol |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
117 :supertype 'help-xref |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
118 'help-function #'help-xref-interned |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
119 '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
|
120 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
121 (define-button-type 'help-back |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
122 :supertype 'help-xref |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
123 'help-function #'help-xref-go-back |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
124 '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
|
125 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
126 (define-button-type 'help-info |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
127 :supertype 'help-xref |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
128 'help-function #'info |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
129 'help-echo (purecopy"mouse-2, RET: read this Info node")) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
130 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
131 (define-button-type 'help-customize-variable |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
132 :supertype 'help-xref |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
133 'help-function (lambda (v) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
134 (if help-xref-stack |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
135 (pop help-xref-stack)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
136 (customize-variable v)) |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
137 '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
|
138 |
39800
8f2810b5b5e8
(help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents:
39787
diff
changeset
|
139 (define-button-type 'help-customize-face |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
140 :supertype 'help-xref |
39800
8f2810b5b5e8
(help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents:
39787
diff
changeset
|
141 'help-function (lambda (v) |
8f2810b5b5e8
(help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents:
39787
diff
changeset
|
142 (if help-xref-stack |
8f2810b5b5e8
(help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents:
39787
diff
changeset
|
143 (pop help-xref-stack)) |
8f2810b5b5e8
(help-customize-face): New button-type.
Miles Bader <miles@gnu.org>
parents:
39787
diff
changeset
|
144 (customize-face v)) |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
145 '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
|
146 |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
147 (define-button-type 'help-function-def |
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 (lambda (fun file) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
150 (require 'find-func) |
55233
038fab289258
(help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55010
diff
changeset
|
151 (when (eq file 'C-source) |
038fab289258
(help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55010
diff
changeset
|
152 (setq file |
038fab289258
(help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55010
diff
changeset
|
153 (help-C-file-name (indirect-function fun) 'fun))) |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
154 ;; 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
|
155 ;; aliases (which fails for built-in functions). |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
156 (let ((location |
55233
038fab289258
(help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55010
diff
changeset
|
157 (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
|
158 (pop-to-buffer (car location)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
159 (goto-char (cdr location)))) |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
160 '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
|
161 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
162 (define-button-type 'help-variable-def |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
163 :supertype 'help-xref |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
164 'help-function (lambda (var &optional file) |
55233
038fab289258
(help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55010
diff
changeset
|
165 (when (eq file 'C-source) |
038fab289258
(help-function-def, help-variable-def):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55010
diff
changeset
|
166 (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
|
167 (let ((location (find-variable-noselect var file))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
168 (pop-to-buffer (car location)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
169 (goto-char (cdr location)))) |
40638
84e66cdcffc5
(help-xref): New button type.
Miles Bader <miles@gnu.org>
parents:
40191
diff
changeset
|
170 '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
|
171 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
172 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
173 ;;;###autoload |
41331
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
174 (defun help-mode () |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
175 "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
|
176 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
|
177 Commands: |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
178 \\{help-mode-map}" |
41331
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
179 (interactive) |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
180 (kill-all-local-variables) |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
181 (use-local-map help-mode-map) |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
182 (setq mode-name "Help") |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
183 (setq major-mode 'help-mode) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
184 (view-mode) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
185 (make-local-variable 'view-no-disable-on-exit) |
41331
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
186 (setq view-no-disable-on-exit t) |
8fa706b1026c
(help-mode): Undo 2001-10-07 change.
Richard M. Stallman <rms@gnu.org>
parents:
40638
diff
changeset
|
187 (run-hooks 'help-mode-hook)) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
188 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
189 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
190 (defun help-mode-setup () |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
191 (help-mode) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
192 (setq buffer-read-only nil)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
193 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
194 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
195 (defun help-mode-finish () |
55010
734c2a20e3ec
(help-mode-finish): Set help-return-alist first
Richard M. Stallman <rms@gnu.org>
parents:
54781
diff
changeset
|
196 (let ((entry (assq (selected-window) view-return-to-alist))) |
60462
df46d87c0c2f
(help-mode-finish): Don't alter the element
Richard M. Stallman <rms@gnu.org>
parents:
59020
diff
changeset
|
197 (if entry |
df46d87c0c2f
(help-mode-finish): Don't alter the element
Richard M. Stallman <rms@gnu.org>
parents:
59020
diff
changeset
|
198 ;; When entering Help mode from the Help window, |
df46d87c0c2f
(help-mode-finish): Don't alter the element
Richard M. Stallman <rms@gnu.org>
parents:
59020
diff
changeset
|
199 ;; such as by following a link, preserve the same |
df46d87c0c2f
(help-mode-finish): Don't alter the element
Richard M. Stallman <rms@gnu.org>
parents:
59020
diff
changeset
|
200 ;; meaning for the q command. |
df46d87c0c2f
(help-mode-finish): Don't alter the element
Richard M. Stallman <rms@gnu.org>
parents:
59020
diff
changeset
|
201 ;; (setcdr entry (cons (selected-window) help-return-method)) |
df46d87c0c2f
(help-mode-finish): Don't alter the element
Richard M. Stallman <rms@gnu.org>
parents:
59020
diff
changeset
|
202 nil |
55010
734c2a20e3ec
(help-mode-finish): Set help-return-alist first
Richard M. Stallman <rms@gnu.org>
parents:
54781
diff
changeset
|
203 (setq view-return-to-alist |
734c2a20e3ec
(help-mode-finish): Set help-return-alist first
Richard M. Stallman <rms@gnu.org>
parents:
54781
diff
changeset
|
204 (cons (cons (selected-window) help-return-method) |
734c2a20e3ec
(help-mode-finish): Set help-return-alist first
Richard M. Stallman <rms@gnu.org>
parents:
54781
diff
changeset
|
205 view-return-to-alist)))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
206 (when (eq major-mode 'help-mode) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
207 ;; 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
|
208 ;; by with-output-to-temp-buffer. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
209 (toggle-read-only 1) |
55010
734c2a20e3ec
(help-mode-finish): Set help-return-alist first
Richard M. Stallman <rms@gnu.org>
parents:
54781
diff
changeset
|
210 (help-make-xrefs (current-buffer)))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
211 |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
212 ;; Grokking cross-reference information in doc strings and |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
213 ;; hyperlinking it. |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
214 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
215 ;; 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
|
216 ;; 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
|
217 ;; another mechanism. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
218 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
219 (defvar help-back-label (purecopy "[back]") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
220 "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
|
221 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
222 (defconst help-xref-symbol-regexp |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
223 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|" |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
224 "\\(function\\|command\\)\\|" |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
225 "\\(face\\)\\|" |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
226 "\\(symbol\\)\\|" |
52876
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
227 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)" |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
228 "[ \t\n]+\\)?" |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
229 ;; Note starting with word-syntax character: |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
230 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'")) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
231 "Regexp matching doc string references to symbols. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
232 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
233 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
|
234 distinguish references to variables, functions and symbols.") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
235 |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
236 (defvar help-xref-mule-regexp nil |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
237 "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
|
238 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
239 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
|
240 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
|
241 `describe-coding-system') are invoked.") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
242 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
243 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
244 (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
|
245 (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
|
246 "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
|
247 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
248 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
249 (defun help-setup-xref (item interactive-p) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
250 "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
|
251 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 items for help buffer \"back\" buttons is cleared. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
256 |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
257 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
|
258 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
|
259 restore it properly when going back." |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
260 (with-current-buffer (help-buffer) |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
261 (when help-xref-stack-item |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
262 (push (cons (point) help-xref-stack-item) help-xref-stack)) |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
263 (when interactive-p |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
264 (let ((tail (nthcdr 10 help-xref-stack))) |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
265 ;; Truncate the stack. |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
266 (if tail (setcdr tail nil)))) |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
267 (setq help-xref-stack-item item))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
268 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
269 (defvar help-xref-following nil |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
270 "Non-nil when following a help cross-reference.") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
271 |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
272 (defun help-buffer () |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
273 (buffer-name ;for with-output-to-temp-buffer |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
274 (if help-xref-following |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
275 (current-buffer) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
276 (get-buffer-create "*Help*")))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
277 |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
278 (defvar help-xref-override-view-map |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
279 (let ((map (make-sparse-keymap))) |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
280 (set-keymap-parent map view-mode-map) |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
281 (define-key map "\r" nil) |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
282 map) |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
283 "Replacement keymap for `view-mode' in help buffers.") |
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
284 |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
285 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
286 (defun help-make-xrefs (&optional buffer) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
287 "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
|
288 |
45763
6499a200d5d5
(help-mode): Don't set `font-lock-defaults'.
Colin Walters <walters@gnu.org>
parents:
42680
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 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
|
293 `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
|
294 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
|
295 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
|
296 preceded by the word `variable' or `option'. |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
297 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
298 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
|
299 cross-reference information related to multilingual environment |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
300 \(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
|
301 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
|
302 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
303 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
|
304 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
|
305 that." |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
306 (interactive "b") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
307 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
308 (set-buffer (or buffer (current-buffer))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
309 (goto-char (point-min)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
310 ;; 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
|
311 ;; 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
|
312 (forward-paragraph) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
313 (let ((old-modified (buffer-modified-p))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
314 (let ((stab (syntax-table)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
315 (case-fold-search t) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
316 (inhibit-read-only t)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
317 (set-syntax-table emacs-lisp-mode-syntax-table) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
318 ;; The following should probably be abstracted out. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
319 (unwind-protect |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
320 (progn |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
321 ;; Info references |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
322 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
323 (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
|
324 (let ((data (match-string 2))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
325 (save-match-data |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
326 (unless (string-match "^([^)]+)" data) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
327 (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
|
328 (help-xref-button 2 'help-info data)))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
329 ;; Mule related keywords. Do this before trying |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
330 ;; `help-xref-symbol-regexp' because some of Mule |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
331 ;; keywords have variable or function definitions. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
332 (if help-xref-mule-regexp |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
333 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
334 (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
|
335 (let* ((data (match-string 7)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
336 (sym (intern-soft data))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
337 (cond |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
338 ((match-string 3) ; coding system |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
339 (and sym (coding-system-p sym) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
340 (help-xref-button 6 'help-coding-system sym))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
341 ((match-string 4) ; input method |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
342 (and (assoc data input-method-alist) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
343 (help-xref-button 7 'help-input-method data))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
344 ((or (match-string 5) (match-string 6)) ; charset |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
345 (and sym (charsetp sym) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
346 (help-xref-button 7 'help-character-set sym))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
347 ((assoc data input-method-alist) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
348 (help-xref-button 7 'help-character-set data)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
349 ((and sym (coding-system-p sym)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
350 (help-xref-button 7 'help-coding-system sym)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
351 ((and sym (charsetp sym)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
352 (help-xref-button 7 'help-character-set sym))))))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
353 ;; Quoted symbols |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
354 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
355 (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
|
356 (let* ((data (match-string 8)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
357 (sym (intern-soft data))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
358 (if sym |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
359 (cond |
52876
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
360 ((match-string 3) ; `variable' &c |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
361 (and (boundp sym) ; `variable' doesn't ensure |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
362 ; it's actually bound |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
363 (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
|
364 ((match-string 4) ; `function' &c |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
365 (and (fboundp sym) ; similarly |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
366 (help-xref-button 8 'help-function sym))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
367 ((match-string 5) ; `face' |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
368 (and (facep sym) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
369 (help-xref-button 8 'help-face sym))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
370 ((match-string 6)) ; nothing for `symbol' |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
371 ((match-string 7) |
52876
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
372 ;;; this used: |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
373 ;;; #'(lambda (arg) |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
374 ;;; (let ((location |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
375 ;;; (find-function-noselect arg))) |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
376 ;;; (pop-to-buffer (car location)) |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
377 ;;; (goto-char (cdr location)))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
378 (help-xref-button 8 'help-function-def 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
|
379 ((facep sym) |
8221f516da37
(help-make-xrefs): Make sure that if a symbol is followed by the word
Luc Teirlinck <teirllm@auburn.edu>
parents:
52878
diff
changeset
|
380 (if (save-match-data (looking-at "[ \t\n]+face\\W")) |
8221f516da37
(help-make-xrefs): Make sure that if a symbol is followed by the word
Luc Teirlinck <teirllm@auburn.edu>
parents:
52878
diff
changeset
|
381 (help-xref-button 8 'help-face sym))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
382 ((and (boundp sym) (fboundp sym)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
383 ;; We can't intuit whether to use the |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
384 ;; variable or function doc -- supply both. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
385 (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
|
386 ((and |
64833a41c107
(help-xref-symbol-regexp): Treat newlines as whitespace.
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
387 (boundp sym) |
54717
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
388 (or |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
389 (documentation-property |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
390 sym 'variable-documentation) |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
391 (condition-case nil |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
392 (documentation-property |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
393 (indirect-variable sym) |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
394 'variable-documentation) |
a0b481c8f7d5
(help-make-xrefs): Recognize aliased variable with
Jesper Harder <harder@ifa.au.dk>
parents:
53455
diff
changeset
|
395 (cyclic-variable-indirection nil)))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
396 (help-xref-button 8 'help-variable sym)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
397 ((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
|
398 (help-xref-button 8 'help-function sym))))))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
399 ;; An obvious case of a key substitution: |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
400 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
401 (while (re-search-forward |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
402 ;; Assume command name is only word characters |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
403 ;; and dashes to get things like `use M-x foo.'. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
404 "\\<M-x\\s-+\\(\\sw\\(\\sw\\|-\\)+\\)" nil t) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
405 (let ((sym (intern-soft (match-string 1)))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
406 (if (fboundp sym) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
407 (help-xref-button 1 'help-function sym))))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
408 ;; Look for commands in whole keymap substitutions: |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
409 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
410 ;; Make sure to find the first keymap. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
411 (goto-char (point-min)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
412 ;; 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
|
413 ;; 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
|
414 |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
415 ;; 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
|
416 ;; 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
|
417 ;; 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
|
418 (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
|
419 nil t) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
420 (let ((col (- (match-end 1) (match-beginning 1)))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
421 (while |
50684
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
422 (and (not (eobp)) |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
423 ;; 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
|
424 (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
|
425 ;; 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
|
426 (and (eolp) (forward-line)) |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
427 (end-of-line) |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
428 (skip-chars-backward "^\t\n") |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
429 (if (and (>= (current-column) col) |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
430 (looking-at "\\(\\sw\\|-\\)+$")) |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
431 (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
|
432 (if (fboundp sym) |
21af30889a41
(help-make-xrefs): Clean up the loop that scans
Richard M. Stallman <rms@gnu.org>
parents:
49690
diff
changeset
|
433 (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
|
434 (forward-line)))))) |
e2879cfe85cf
(help-make-xrefs): Remove extra paren.
John Paul Wallington <jpw@pobox.com>
parents:
50684
diff
changeset
|
435 (set-syntax-table stab)) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
436 ;; 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
|
437 (goto-char (point-max)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
438 (while (and (not (bobp)) (bolp)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
439 (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
|
440 (insert "\n") |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
441 ;; 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
|
442 (when help-xref-stack |
54781
bdfa0aa8c425
(help-make-xrefs): Add a final newline to the *Help* buffer.
Juri Linkov <juri@jurta.org>
parents:
54748
diff
changeset
|
443 (insert "\n") |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
444 (help-insert-xref-button help-back-label 'help-back |
54781
bdfa0aa8c425
(help-make-xrefs): Add a final newline to the *Help* buffer.
Juri Linkov <juri@jurta.org>
parents:
54748
diff
changeset
|
445 (current-buffer)) |
bdfa0aa8c425
(help-make-xrefs): Add a final newline to the *Help* buffer.
Juri Linkov <juri@jurta.org>
parents:
54748
diff
changeset
|
446 (insert "\n"))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
447 ;; View mode steals RET from us. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
448 (set (make-local-variable 'minor-mode-overriding-map-alist) |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
449 (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
|
450 (set-buffer-modified-p old-modified)))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
451 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
452 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
453 (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
|
454 "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
|
455 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
|
456 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
|
457 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
|
458 See `help-make-xrefs'." |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
459 ;; 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
|
460 (unless (button-at (match-beginning match-number)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
461 (make-text-button (match-beginning match-number) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
462 (match-end match-number) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
463 'type type 'help-args args))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
464 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
465 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
466 (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
|
467 "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
|
468 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
|
469 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
|
470 See `help-make-xrefs'." |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
471 (unless (button-at (point)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
472 (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
|
473 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
474 ;;;###autoload |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
475 (defun help-xref-on-pp (from to) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
476 "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
|
477 (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
|
478 (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
|
479 (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
|
480 (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
|
481 (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
|
482 (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
|
483 (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
|
484 (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
|
485 (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
|
486 ((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
|
487 ((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
|
488 ((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
|
489 (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
|
490 (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
|
491 ((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
|
492 (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
|
493 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
|
494 ((and sym (boundp 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
|
495 '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
|
496 (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
|
497 (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
|
498 (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
|
499 (error nil))))))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
500 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
501 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
502 ;; 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
|
503 (defun help-xref-interned (symbol) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
504 "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
|
505 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
|
506 help buffer." |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
507 (with-current-buffer (help-buffer) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
508 ;; Push the previous item on the stack before clobbering the output buffer. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
509 (help-setup-xref nil nil) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
510 (let ((facedoc (when (facep symbol) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
511 ;; Don't record the current entry in the stack. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
512 (setq help-xref-stack-item nil) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
513 (describe-face symbol))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
514 (fdoc (when (fboundp symbol) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
515 ;; Don't record the current entry in the stack. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
516 (setq help-xref-stack-item nil) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
517 (describe-function symbol))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
518 (sdoc (when (boundp symbol) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
519 ;; Don't record the current entry in the stack. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
520 (setq help-xref-stack-item nil) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
521 (describe-variable symbol)))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
522 (cond |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
523 (sdoc |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
524 ;; We now have a help buffer on the variable. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
525 ;; Insert the function and face text before it. |
42593 | 526 (when (or fdoc facedoc) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
527 (goto-char (point-min)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
528 (let ((inhibit-read-only t)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
529 (when fdoc |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
530 (insert fdoc "\n\n") |
42593 | 531 (when facedoc |
532 (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
|
533 " is also a " "face." "\n\n"))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
534 (when facedoc |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
535 (insert facedoc "\n\n")) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
536 (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
|
537 " is also a " "variable." "\n\n")) |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
538 ;; 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
|
539 (setq help-xref-stack-item nil) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
540 (help-setup-xref (list #'help-xref-interned symbol) nil))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
541 (fdoc |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
542 ;; We now have a help buffer on the function. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
543 ;; Insert face text before it. |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
544 (when facedoc |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
545 (goto-char (point-max)) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
546 (let ((inhibit-read-only t)) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
547 (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
|
548 " is also a " "face." "\n\n" facedoc)) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
549 ;; 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
|
550 (setq help-xref-stack-item nil) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
551 (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
|
552 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
553 |
46437
6987a52d9b98
(view): Always require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45767
diff
changeset
|
554 ;; Navigation/hyperlinking with xrefs |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
555 |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
556 (defun help-follow-mouse (click) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
557 "Follow the cross-reference that you CLICK on." |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
558 (interactive "e") |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
559 (let* ((start (event-start click)) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
560 (window (car start)) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
561 (pos (car (cdr start)))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
562 (with-current-buffer (window-buffer window) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
563 (help-follow pos)))) |
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
564 |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
565 (defun help-xref-go-back (buffer) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
566 "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
|
567 (let (item position method args) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
568 (with-current-buffer buffer |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
569 (when help-xref-stack |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
570 (setq item (pop help-xref-stack) |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
571 ;; 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
|
572 ;; 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
|
573 ;; 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
|
574 help-xref-stack-item nil |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
575 position (car item) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
576 method (cadr item) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
577 args (cddr item)))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
578 (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
|
579 (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
|
580 (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
|
581 (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
|
582 (goto-char position))))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
583 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
584 (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
|
585 "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
|
586 (interactive) |
55679
839ccd7aaee0
(help-go-back): Don't depend on position of back button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55233
diff
changeset
|
587 (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
|
588 (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
|
589 (error "No previous help buffer"))) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
590 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
591 (defun help-do-xref (pos function args) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
592 "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
|
593 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
|
594 a proper [back] button." |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
595 ;; There is a reference at point. Follow it. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
596 (let ((help-xref-following t)) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
597 (apply function args))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
598 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
599 (defun help-follow (&optional pos) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
600 "Follow cross-reference at POS, defaulting to point. |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
601 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
602 For the cross-reference format, see `help-make-xrefs'." |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
603 (interactive "d") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
604 (unless pos |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
605 (setq pos (point))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
606 (unless (push-button pos) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
607 ;; check if the symbol under point is a function or variable |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
608 (let ((sym |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
609 (intern |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
610 (save-excursion |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
611 (goto-char pos) (skip-syntax-backward "w_") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
612 (buffer-substring (point) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
613 (progn (skip-syntax-forward "w_") |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
614 (point))))))) |
39787
b44e34df3fa2
(help-buffer): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39727
diff
changeset
|
615 (when (or (boundp sym) (fboundp sym) (facep sym)) |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
616 (help-do-xref pos #'help-xref-interned (list sym)))))) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
617 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
618 |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
619 (provide 'help-mode) |
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
620 |
52401 | 621 ;;; arch-tag: 850954ae-3725-4cb4-8e91-0bf6d52d6b0b |
39727
3806fe844742
New file, contents mostly from `help.el'.
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
622 ;;; help-mode.el ends here |