0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: hmous-info.el
|
|
4 ;; SUMMARY: Walks through Info networks using one key.
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: docs, help, hypermedia, mouse
|
|
7 ;;
|
|
8 ;; AUTHOR: Bob Weiner
|
|
9 ;; ORIG-DATE: 04-Apr-89
|
|
10 ;; LAST-MOD: 1-Nov-95 at 20:33:46 by Bob Weiner
|
|
11 ;;
|
|
12 ;; This file is for use with Hyperbole.
|
|
13 ;;
|
|
14 ;; Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
|
|
15 ;; Available for use and distribution under the same terms as GNU Emacs.
|
|
16 ;;
|
|
17 ;;
|
|
18 ;; DESCRIPTION:
|
|
19 ;;
|
|
20 ;; This code is machine independent.
|
|
21 ;;
|
|
22 ;; To install: See hui-mouse.el
|
|
23 ;;
|
|
24 ;; DESCRIP-END.
|
|
25
|
|
26 ;;;###autoload
|
|
27 (defun smart-info ()
|
|
28 "Walks through Info documentation networks using one key or mouse key.
|
|
29
|
|
30 If key is pressed within:
|
|
31 (1) the first line of an Info Menu Entry or Cross Reference, the desired node
|
|
32 is found;
|
|
33 (2) the Up, Next, or Previous entries of a Node Header (first line),
|
|
34 the desired node is found;
|
|
35 (3) the File entry of a Node Header (first line),
|
|
36 the 'Top' node within that file is found;
|
|
37 (4) at the end of the current node, the Next node is found (this will
|
|
38 descend subtrees if the function 'Info-global-next' is bound);
|
|
39 (5) anywhere else (e.g. at the end of a line), the current node entry is
|
|
40 scrolled up one windowful.
|
|
41
|
|
42 Returns t if key is pressed within an Info Node Header, Cross Reference,
|
|
43 or a Menu; otherwise returns nil."
|
|
44
|
|
45 (interactive)
|
|
46 (cond
|
|
47 ;;
|
|
48 ;; If at end of node, go to next node
|
|
49 ;;
|
|
50 ((last-line-p)
|
|
51 (if (fboundp 'Info-global-next) (Info-global-next)
|
|
52 (Info-next)))
|
|
53 ((Info-handle-in-node-hdr))
|
|
54 ((Info-handle-in-note))
|
|
55 ((Info-handle-in-menu))
|
|
56 ((pos-visible-in-window-p (point-max))
|
|
57 (if (fboundp 'Info-global-next) (Info-global-next)
|
|
58 (Info-next)))
|
|
59 ;;
|
|
60 ;; If nothing else scroll forward a windowful.
|
|
61 ;;
|
|
62 ((smart-scroll-up))))
|
|
63
|
|
64 ;;;###autoload
|
|
65 (defun smart-info-assist ()
|
|
66 "Walks through Info documentation networks using one assist-key or mouse assist-key.
|
|
67
|
|
68 If assist-key is pressed within:
|
|
69 (1) the first line of an Info Menu Entry or Cross Reference, the desired node
|
|
70 is found;
|
|
71 (2) the Up, Next, or Previous entries of a Node Header (first line),
|
|
72 the last node in the history list is found;
|
|
73 (3) the File entry of a Node Header (first line),
|
|
74 the 'DIR' root-level node is found;
|
|
75 (4) at the end of the current node, the Previous node is found (this will
|
|
76 return from subtrees if the function 'Info-global-prev is bound);
|
|
77 (5) anywhere else (e.g. at the end of a line), the current node entry is
|
|
78 scrolled down one windowful.
|
|
79
|
|
80 Returns t if assist-key is pressed within an Info Node Header, Cross Reference,
|
|
81 or a Menu; otherwise returns nil."
|
|
82
|
|
83 (interactive)
|
|
84 (cond
|
|
85 ;;
|
|
86 ;; If at end or beginning of node, go to previous node
|
|
87 ;;
|
|
88 ((last-line-p)
|
|
89 (if (fboundp 'Info-global-prev) (Info-global-prev)
|
|
90 (Info-prev)))
|
|
91 ((Info-handle-in-node-hdr-assist))
|
|
92 ((Info-handle-in-note))
|
|
93 ((Info-handle-in-menu))
|
|
94 ((pos-visible-in-window-p (point-min))
|
|
95 (if (fboundp 'Info-global-prev) (Info-global-prev)
|
|
96 (Info-prev)))
|
|
97 ;;
|
|
98 ;; If anywhere else, scroll backward a windowful.
|
|
99 ;;
|
|
100 ((smart-scroll-down))))
|
|
101
|
|
102 (defun Info-handle-in-node-hdr ()
|
|
103 "If within an Info node header, move to <FILE>Top, <Up>, <Previous>, or
|
|
104 <Next> node, depending on which label point is on, and return t.
|
|
105 Otherwise, return nil."
|
|
106 ;;
|
|
107 ;; Test if on 1st line of node, i.e. node header
|
|
108 ;;
|
|
109 (if (not (first-line-p))
|
|
110 nil
|
|
111 (let ((nodename "Top") (filep nil))
|
|
112 (save-excursion
|
|
113 (if (and
|
|
114 (re-search-forward "[:, \t\n]" nil t)
|
|
115 (re-search-backward
|
|
116 "\\(File\\|Node\\|Up\\|Prev\\|Previous\\|Next\\):[ \t]" nil t))
|
|
117 (progn (setq filep (string-equal
|
|
118 "file"
|
|
119 (downcase (buffer-substring
|
|
120 (match-beginning 1)
|
|
121 (match-end 1)))))
|
|
122 (if (re-search-forward (concat ":[ \n]\\([^,\t\n"
|
|
123 (if filep " ")
|
|
124 "]*\\)") nil t)
|
|
125 (setq nodename (buffer-substring
|
|
126 (match-beginning 1)
|
|
127 (match-end 1)))))
|
|
128 (error "Node header not found.")))
|
|
129 (setq nodename
|
|
130 (cond ((= (aref nodename 0) ?\() nodename)
|
|
131 (filep (concat "(" nodename ")" "Top"))
|
|
132 (buffer-file-name (concat "(" buffer-file-name ")" nodename))
|
|
133 (t nodename)))
|
|
134 (if hyperb:lemacs-p
|
|
135 (Info-goto-node nodename nil t)
|
|
136 (Info-goto-node nodename))
|
|
137 t)))
|
|
138
|
|
139 (defun Info-handle-in-node-hdr-assist ()
|
|
140 "If within an Info node header when the 'smart-info-assist' command is
|
|
141 executed, when within the <FILE> header go to the DIR top-level node. When
|
|
142 within any other header (<Up>, <Previous>, or <Next>) go to last node from
|
|
143 history list. Return t if in Info node header. Otherwise return nil."
|
|
144 ;;
|
|
145 ;; Test if on 1st line of node, i.e. node header
|
|
146 ;;
|
|
147 (if (not (first-line-p))
|
|
148 nil
|
|
149 (save-excursion
|
|
150 (if (and
|
|
151 (re-search-forward "[:, \t\n]" nil t)
|
|
152 (re-search-backward
|
|
153 "\\(File\\|Node\\|Up\\|Prev\\|Previous\\|Next\\):[ \t]" nil t) )
|
|
154 ;; If in <FILE> hdr
|
|
155 (progn (if (string-equal
|
|
156 "file"
|
|
157 (downcase (buffer-substring
|
|
158 (match-beginning 1)
|
|
159 (match-end 1))))
|
|
160 (Info-directory)
|
|
161 (Info-last))
|
|
162 t)
|
|
163 (error "Node header not found.")
|
|
164 nil))))
|
|
165
|
|
166 ;;;###autoload
|
|
167 (defun Info-handle-in-note ()
|
|
168 "Follows an Info cross-reference.
|
|
169 If point is within the first line of an Info note (cross-reference), follows
|
|
170 cross-reference and returns t; otherwise returns nil."
|
|
171 (let ((note-name) (opoint (point)))
|
|
172 (save-excursion
|
|
173 (skip-chars-forward "^:")
|
|
174 (if (and (re-search-backward
|
|
175 "\*\\(Ref\\|Note\\|See\\)\\([ \t\n]+\\|$\\)" nil t)
|
|
176 (looking-at "\*\\(Ref\\|Note\\|See\\)[ \t\n]+\\([^:]*\\):")
|
|
177 (<= (match-beginning 0) opoint)
|
|
178 (> (match-end 0) opoint))
|
|
179 ;; Remove newline and extra spaces from 'note-name'
|
|
180 (setq note-name (hypb:replace-match-string
|
|
181 "[ \n\t]+"
|
|
182 (buffer-substring
|
|
183 (match-beginning 2) (match-end 2))
|
|
184 " " t))))
|
|
185 (if note-name
|
|
186 (progn (Info-follow-reference note-name) t))))
|
|
187
|
|
188 (defun Info-handle-in-menu ()
|
|
189 "Displays node referred to by an Info Menu Entry.
|
|
190 If point is within an Info menu entry, goes to node referenced by
|
|
191 entry and returns t; otherwise returns nil."
|
|
192 ;;
|
|
193 ;; Test if there is a menu in this node
|
|
194 ;;
|
|
195 (let ((in-menu nil) (curr-point (point)))
|
|
196 (save-excursion
|
|
197 (goto-char (point-min))
|
|
198 (setq in-menu
|
|
199 (and (search-forward "\n* menu:" nil t)
|
|
200 (< (point) curr-point))))
|
|
201 (if (not in-menu)
|
|
202 nil
|
|
203 (let ((node))
|
|
204 (save-excursion
|
|
205 (forward-char) ; Pass '*' char if point is in front of
|
|
206 (if (search-backward "\n*" nil t)
|
|
207 (progn (forward-char 2)
|
|
208 (setq node (Info-extract-menu-node-name)))))
|
|
209 (if (null node)
|
|
210 nil
|
|
211 (if hyperb:lemacs-p
|
|
212 (Info-goto-node node nil t)
|
|
213 (Info-goto-node node))
|
|
214 t)))))
|
|
215
|
|
216 (provide 'hmous-info)
|