Mercurial > hg > xemacs-beta
comparison lisp/hyperbole/hactypes.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 4103f0995bd7 |
children | 4be1180a9e89 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
4 ;; SUMMARY: Default action types for Hyperbole. | 4 ;; SUMMARY: Default action types for Hyperbole. |
5 ;; USAGE: GNU Emacs Lisp Library | 5 ;; USAGE: GNU Emacs Lisp Library |
6 ;; KEYWORDS: extensions, hypermedia | 6 ;; KEYWORDS: extensions, hypermedia |
7 ;; | 7 ;; |
8 ;; AUTHOR: Bob Weiner | 8 ;; AUTHOR: Bob Weiner |
9 ;; ORG: InfoDock Associates | 9 ;; ORG: Brown U. |
10 ;; | |
11 ;; This file is part of Hyperbole. | |
12 ;; Available for use and distribution under the same terms as GNU Emacs. | |
13 ;; | |
14 ;; Copyright (C) 1991-1997 Free Software Foundation, Inc. | |
15 ;; Developed with support from Motorola Inc. | |
16 ;; | 10 ;; |
17 ;; ORIG-DATE: 23-Sep-91 at 20:34:36 | 11 ;; ORIG-DATE: 23-Sep-91 at 20:34:36 |
18 ;; LAST-MOD: 20-Feb-97 at 11:16:36 by Bob Weiner | 12 ;; LAST-MOD: 28-Oct-95 at 02:33:45 by Bob Weiner |
19 | |
20 ;;; ************************************************************************ | 13 ;;; ************************************************************************ |
21 ;;; Other required Elisp libraries | 14 ;;; Other required Elisp libraries |
22 ;;; ************************************************************************ | 15 ;;; ************************************************************************ |
23 | 16 |
24 (mapcar 'require '(hbut hpath hargs hact hmail)) | 17 (mapcar 'require '(hbut hpath hargs hact hmail)) |
28 ;;; ************************************************************************ | 21 ;;; ************************************************************************ |
29 | 22 |
30 (defact annot-bib (key) | 23 (defact annot-bib (key) |
31 "Follows internal ref KEY within an annotated bibliography, delimiters=[]." | 24 "Follows internal ref KEY within an annotated bibliography, delimiters=[]." |
32 (interactive "sReference key (no []): ") | 25 (interactive "sReference key (no []): ") |
33 (let ((opoint (point)) | 26 (let ((opoint (point))) |
34 (key-regexp (concat "^[*]*[ \t]*\\\[" (ebut:key-to-label key) "\\\]"))) | 27 (goto-char 1) |
35 (goto-char (point-min)) | 28 (if (re-search-forward |
36 (if (re-search-forward key-regexp nil t) | 29 (concat "^[*]*[ \t]*\\\[" (ebut:key-to-label key) "\\\]") nil t) |
37 (progn (hpath:display-buffer (current-buffer)) | 30 (progn |
38 (beginning-of-line)) | 31 (beginning-of-line) |
39 (goto-char opoint) | 32 (delete-other-windows) |
40 (beep)))) | 33 (split-window-vertically nil) |
34 (goto-char opoint)) | |
35 (beep)) | |
36 (goto-char opoint))) | |
41 | 37 |
42 (defact completion () | 38 (defact completion () |
43 "Inserts completion at point into the minibuffer or a buffer. | 39 "Inserts completion at point into minibuffer or other window. |
44 Unless point is at the end of the buffer or if completion has already been | 40 Unless at end of buffer or if completion has already been inserted, then |
45 inserted, the completions window is deleted." | 41 deletes completions window." |
46 (interactive) | 42 (interactive) |
47 (if (eobp) | 43 (if (eobp) |
48 (progn (bury-buffer nil) | 44 (progn (bury-buffer nil) |
49 (delete-window)) | 45 (delete-window)) |
50 (hargs:completion))) | 46 (hargs:completion))) |
72 nil "nil" 'symbol))) | 68 nil "nil" 'symbol))) |
73 (cond ((fboundp macro)) | 69 (cond ((fboundp macro)) |
74 ((null last-kbd-macro) | 70 ((null last-kbd-macro) |
75 (hypb:error | 71 (hypb:error |
76 "(exec-kbd-macro): Define a keyboard macro first.")) | 72 "(exec-kbd-macro): Define a keyboard macro first.")) |
77 (t (fset 'zzk last-kbd-macro) | 73 (t (fset 'zzz last-kbd-macro) |
78 (setq macro 'zzk))) | 74 (setq macro 'zzz))) |
79 (save-excursion | 75 (save-excursion |
80 (let ((standard-output (get-buffer-create "*macro-def*"))) | 76 (let ((standard-output (get-buffer-create "*macro-def*"))) |
81 (unwind-protect | 77 (unwind-protect |
82 (progn (set-buffer standard-output) | 78 (progn (set-buffer standard-output) |
83 (setq buffer-read-only nil) | 79 (setq buffer-read-only nil) |
84 (erase-buffer) | 80 (erase-buffer) |
85 (insert-kbd-macro macro) | 81 (insert-kbd-macro macro) |
86 (goto-char (point-min)) | 82 (goto-char (point-min)) |
87 (setq macro (car (cdr (cdr (read (current-buffer))))))) | 83 (setq macro (car (cdr (cdr (read (current-buffer))))))) |
88 (kill-buffer standard-output)))) | 84 (kill-buffer standard-output)))) |
89 (fmakunbound 'zzk) | 85 (fmakunbound 'zzz) |
90 (setq repeat (hargs:read "Repeat count: " | 86 (setq repeat (hargs:read "Repeat count: " |
91 (function | 87 (function |
92 (lambda (repeat) | 88 (lambda (repeat) |
93 (or (null repeat) | 89 (or (null repeat) |
94 (and (integerp repeat) (>= repeat 0))))) | 90 (and (integerp repeat) (>= repeat 0))))) |
101 (hypb:error "(exec-kbd-macro): Bad macro: %s" kbd-macro)) | 97 (hypb:error "(exec-kbd-macro): Bad macro: %s" kbd-macro)) |
102 (or (null repeat-count) (and (integerp repeat-count) (<= 0 repeat-count)) | 98 (or (null repeat-count) (and (integerp repeat-count) (<= 0 repeat-count)) |
103 (hypb:error "(exec-kbd-macro): Bad repeat count: %s" repeat-count))) | 99 (hypb:error "(exec-kbd-macro): Bad repeat count: %s" repeat-count))) |
104 (execute-kbd-macro kbd-macro repeat-count)) | 100 (execute-kbd-macro kbd-macro repeat-count)) |
105 | 101 |
106 ;;; Support next two actypes on systems which use the `comint' shell package | 102 ;;; Support next two actypes on systems which use the 'comint' shell package |
107 ;;; rather than Emacs V18 shell.el. | 103 ;;; rather than Emacs V18 shell.el. |
108 ;;; | 104 ;;; |
109 (if (or hyperb:lemacs-p hyperb:emacs19-p) | 105 (if (or hyperb:lemacs-p hyperb:emacs19-p) |
110 (require 'comint)) | 106 (require 'comint)) |
111 (and (fboundp 'comint-send-input) (not (fboundp 'shell-send-input)) | 107 (and (fboundp 'comint-send-input) (not (fboundp 'shell-send-input)) |
117 | 113 |
118 (defact exec-shell-cmd (shell-cmd &optional internal-cmd kill-prev) | 114 (defact exec-shell-cmd (shell-cmd &optional internal-cmd kill-prev) |
119 "Executes a SHELL-CMD string asynchronously. | 115 "Executes a SHELL-CMD string asynchronously. |
120 Optional non-nil second argument INTERNAL-CMD means do not display the shell | 116 Optional non-nil second argument INTERNAL-CMD means do not display the shell |
121 command line executed. Optional non-nil third argument KILL-PREV means | 117 command line executed. Optional non-nil third argument KILL-PREV means |
122 kill the last output to the shell buffer before executing SHELL-CMD." | 118 kill last output to shell buffer before executing SHELL-CMD." |
123 (interactive | 119 (interactive |
124 (let ((default (car defaults)) | 120 (let ((default (car defaults)) |
125 (default1 (nth 1 defaults)) | 121 (default1 (nth 1 defaults)) |
126 (default2 (nth 2 defaults))) | 122 (default2 (nth 2 defaults))) |
127 (list (hargs:read "Shell cmd: " | 123 (list (hargs:read "Shell cmd: " |
128 (function | 124 (function |
129 (lambda (cmd) (not (string-equal cmd "")))) | 125 (lambda (cmd) (not (string= cmd "")))) |
130 default "Enter a shell command." 'string) | 126 default "Enter a shell command." 'string) |
131 (y-or-n-p (format "Omit cmd from output (default = %s): " | 127 (y-or-n-p (format "Omit cmd from output (default = %s): " |
132 default1)) | 128 default1)) |
133 (y-or-n-p (format "Kill prior cmd's output (default = %s): " | 129 (y-or-n-p (format "Kill prior cmd's output (default = %s): " |
134 default2))))) | 130 default2))))) |
139 (if (not (hpath:ange-ftp-p default-directory)) | 135 (if (not (hpath:ange-ftp-p default-directory)) |
140 (setq shell-cmd | 136 (setq shell-cmd |
141 (concat "cd " default-directory "; " shell-cmd))) | 137 (concat "cd " default-directory "; " shell-cmd))) |
142 (if (not (get-buffer buf-name)) | 138 (if (not (get-buffer buf-name)) |
143 (save-excursion | 139 (save-excursion |
144 (hpath:display-buffer (current-buffer)) | 140 ;; Ensure shell displays in other window unless in the |
141 ;; OO-Browser, then use selected window. | |
142 (if (br-in-browser) | |
143 nil | |
144 (if (= (length (hypb:window-list)) 1) | |
145 (split-window-vertically)) | |
146 (other-window 1)) | |
145 (if (eq (minibuffer-window) (selected-window)) | 147 (if (eq (minibuffer-window) (selected-window)) |
146 (other-window 1)) | 148 (other-window 1)) |
147 (shell) (rename-buffer buf-name) | 149 (shell) (rename-buffer buf-name) |
148 (setq last-input-start (point-marker) | 150 (setq last-input-start (point-marker) |
149 last-input-end (point-marker)) | 151 last-input-end (point-marker)) |
150 (if (fboundp 'comint-kill-output) | 152 (if (fboundp 'comint-kill-output) |
151 (setq comint-last-input-start last-input-start | 153 (setq comint-last-input-start last-input-start |
152 comint-last-input-end last-input-end) | 154 comint-last-input-end last-input-end) |
153 ))) | 155 ))) |
154 (hpath:display-buffer buf-name) | 156 (or (equal (buffer-name (current-buffer)) buf-name) |
157 (if (br-in-browser) (switch-to-buffer buf-name) | |
158 (pop-to-buffer buf-name))) | |
155 (goto-char (point-max)) | 159 (goto-char (point-max)) |
156 (and kill-prev last-input-end | 160 (and kill-prev last-input-end |
157 (not (equal last-input-start last-input-end)) | 161 (not (equal last-input-start last-input-end)) |
158 (kill-output-from-shell)) | 162 (kill-output-from-shell)) |
159 (insert shell-cmd) | 163 (insert shell-cmd) |
161 (show-output-from-shell) | 165 (show-output-from-shell) |
162 (or internal-cmd (scroll-down 1))) | 166 (or internal-cmd (scroll-down 1))) |
163 (select-window owind)))) | 167 (select-window owind)))) |
164 | 168 |
165 (defact exec-window-cmd (shell-cmd) | 169 (defact exec-window-cmd (shell-cmd) |
166 "Asynchronously executes an external window-based SHELL-CMD string." | 170 "Executes an external window-based SHELL-CMD string asynchronously." |
167 (interactive | 171 (interactive |
168 (let ((default (car defaults))) | 172 (let ((default (car defaults))) |
169 (list (hargs:read "Shell cmd: " | 173 (list (hargs:read "Shell cmd: " |
170 (function | 174 (function |
171 (lambda (cmd) (not (string-equal cmd "")))) | 175 (lambda (cmd) (not (string= cmd "")))) |
172 default "Enter a shell command." 'string)))) | 176 default "Enter a shell command." 'string)))) |
173 (let ((buf-name "*Hypb Shell*") | 177 (let ((buf-name "*Hypb Shell*") |
174 (cmd (if (hpath:ange-ftp-p default-directory) | 178 (cmd (if (hpath:ange-ftp-p default-directory) |
175 (concat "(" shell-cmd ") &") | 179 (concat "(" shell-cmd ") &") |
176 (concat "(cd " default-directory "; " shell-cmd ") &"))) | 180 (concat "(cd " default-directory "; " shell-cmd ") &"))) |
200 (goto-char (point-max)) | 204 (goto-char (point-max)) |
201 (insert cmd) | 205 (insert cmd) |
202 (shell-send-input))) | 206 (shell-send-input))) |
203 (message msg))) | 207 (message msg))) |
204 | 208 |
205 (defact function-in-buffer (name pos) | |
206 "Displays the definition of function NAME found at POS in the current buffer." | |
207 (save-excursion | |
208 (goto-char pos) | |
209 (if (looking-at (regexp-quote name)) | |
210 nil | |
211 (let ((fume-scanning-message nil)) | |
212 (fume-rescan-buffer) | |
213 (setq pos (cdr-safe (assoc name fume-funclist)))))) | |
214 (if pos | |
215 (progn (hpath:display-buffer (current-buffer)) | |
216 (goto-char pos) | |
217 ;; Move to beginning of the line for compatibility with find-tag. | |
218 (beginning-of-line)))) | |
219 | |
220 (defact hyp-config (&optional out-buf) | 209 (defact hyp-config (&optional out-buf) |
221 "Inserts Hyperbole configuration info at end of current buffer or optional OUT-BUF." | 210 "Inserts Hyperbole configuration info at end of optional OUT-BUF or current." |
222 (hypb:configuration out-buf)) | 211 (hypb:configuration out-buf)) |
223 | 212 |
224 (defact hyp-request (&optional out-buf) | 213 (defact hyp-request (&optional out-buf) |
225 "Inserts Hyperbole mail list request help into current buffer or optional OUT-BUF." | 214 "Inserts Hyperbole mail list request help into optional OUT-BUF or current." |
226 (save-excursion | 215 (save-excursion |
227 (and out-buf (set-buffer out-buf)) | 216 (and out-buf (set-buffer out-buf)) |
228 (goto-char (point-max)) | 217 (goto-char (point-max)) |
229 (delete-blank-lines) (delete-blank-lines) | 218 (delete-blank-lines) (delete-blank-lines) |
230 (insert "Use one of the following formats in the *body* of your message:\n | 219 (insert "Use one of the following formats on your subject line:\n |
231 subscribe <mail-list-name> [<your-email-address>] | 220 Subject: Subscribe <joe@any.com> (Joe Williams). |
232 or | 221 Subject: Unsubscribe <joe@any.com>. |
233 unsubscribe <mail-list-name> [<your-email-address>] | 222 |
234 | 223 To change your address, first unsubscribe by sending an unsubscribe |
235 where possible <mail-list-names> are: | 224 request from your old address. Then subscribe by sending a subscribe |
225 request from your new address. | |
226 | |
227 Possible mail lists are: | |
236 hyperbole - discussion of Hyperbole | 228 hyperbole - discussion of Hyperbole |
237 hyperbole-announce - Hyperbole announcements only | 229 hyperbole-announce - Hyperbole announcements only\n"))) |
238 | |
239 For example: subscribe hyperbole joe@nowhere.gov\n"))) | |
240 | 230 |
241 (defact hyp-source (buf-str-or-file) | 231 (defact hyp-source (buf-str-or-file) |
242 "Displays a buffer or file from a line beginning with `hbut:source-prefix'." | 232 "Displays a buffer or file from a line beginning with 'hbut:source-prefix'." |
243 (interactive | 233 (interactive |
244 (list (prin1-to-string (get-buffer-create | 234 (list (prin1-to-string (get-buffer-create |
245 (read-buffer "Buffer to link to: "))))) | 235 (read-buffer "Buffer to link to: "))))) |
246 (if (stringp buf-str-or-file) | 236 (if (stringp buf-str-or-file) |
247 (cond ((string-match "\\`#<buffer \"?\\([^ \n\"]+\\)\"?>" buf-str-or-file) | 237 (cond ((string-match "\\`#<buffer \"?\\([^ \n\"]+\\)\"?>" buf-str-or-file) |
248 (hpath:display-buffer | 238 (pop-to-buffer (substring buf-str-or-file |
249 (substring buf-str-or-file (match-beginning 1) (match-end 1)))) | 239 (match-beginning 1) (match-end 1)))) |
250 (t (hpath:find buf-str-or-file))) | 240 (t (hpath:find-other-window buf-str-or-file))) |
251 (hypb:error "(hyp-source): Non-string argument: %s" buf-str-or-file))) | 241 (hypb:error "(hyp-source): Non-string argument: %s" buf-str-or-file))) |
252 | 242 |
253 (defact link-to-buffer-tmp (buffer) | 243 (defact link-to-buffer-tmp (buffer) |
254 "Displays a BUFFER. | 244 "Displays a BUFFER in another window. |
255 Link is generally only good for current Emacs session. | 245 Link is generally only good for current Emacs session. |
256 Use `link-to-file' instead for a permanent link." | 246 Use 'link-to-file' instead for a permanent link." |
257 (interactive "bBuffer to link to: ") | 247 (interactive "bBuffer to link to: ") |
258 (if (or (stringp buffer) (bufferp buffer)) | 248 (if (or (stringp buffer) (bufferp buffer)) |
259 (hpath:display-buffer buffer) | 249 (pop-to-buffer buffer) |
260 (hypb:error "(link-to-buffer-tmp): Not a current buffer: %s" buffer))) | 250 (hypb:error "(link-to-buffer-tmp): Not a current buffer: %s" buffer))) |
261 | 251 |
262 (defact link-to-directory (directory) | 252 (defact link-to-directory (directory) |
263 "Displays a DIRECTORY in Dired mode." | 253 "Displays a DIRECTORY in Dired mode in another window." |
264 (interactive "DDirectory to link to: ") | 254 (interactive "DDirectory to link to: ") |
265 (hpath:find directory)) | 255 (hpath:find-other-window directory)) |
266 | 256 |
267 (defact link-to-ebut (key-file key) | 257 (defact link-to-ebut (key-file key) |
268 "Performs action given by another button, specified by KEY-FILE and KEY." | 258 "Performs action given by another button, specified by KEY-FILE and KEY." |
269 (interactive | 259 (interactive |
270 (let (but-file but-lbl) | 260 (let (but-file but-lbl) |
271 (while (cond ((setq but-file | 261 (while (cond ((setq but-file |
272 (read-file-name | 262 (read-file-name |
273 "File of button to link to: " nil nil t)) | 263 "File of button to link to: " nil nil t)) |
274 (if (string-equal but-file "") | 264 (if (string= but-file "") |
275 (progn (beep) t))) | 265 (progn (beep) t))) |
276 ((not (file-readable-p but-file)) | 266 ((not (file-readable-p but-file)) |
277 (message "(link-to-ebut): You cannot read `%s'." | 267 (message "(link-to-ebut): You cannot read '%s'." |
278 but-file) | 268 but-file) |
279 (beep) (sit-for 3)))) | 269 (beep) (sit-for 3)))) |
280 (list but-file | 270 (list but-file |
281 (progn | 271 (progn |
282 (find-file-noselect but-file) | 272 (find-file-noselect but-file) |
283 (while (string-equal "" (setq but-lbl | 273 (while (string= "" (setq but-lbl |
284 (hargs:read-match | 274 (hargs:read-match |
285 "Button to link to: " | 275 "Button to link to: " |
286 (ebut:alist but-file) | 276 (ebut:alist but-file) |
287 nil nil nil 'ebut))) | 277 nil nil nil 'ebut))) |
288 (beep)) | 278 (beep)) |
289 (ebut:label-to-key but-lbl))))) | 279 (ebut:label-to-key but-lbl))))) |
290 (or (interactive-p) | 280 (or (interactive-p) |
291 (setq key-file (hpath:validate (hpath:substitute-value key-file)))) | 281 (setq key-file (hpath:validate (hpath:substitute-value key-file)))) |
292 (let ((but (ebut:get key (find-file-noselect key-file)))) | 282 (let ((but (ebut:get key (find-file-noselect key-file)))) |
293 (if but (hbut:act but) | 283 (if but (hbut:act but) |
294 (hypb:error "(link-to-ebut): No button `%s' in `%s'." (ebut:key-to-label key) | 284 (hypb:error "(link-to-ebut): No button '%s' in '%s'." (ebut:key-to-label key) |
295 key-file)))) | 285 key-file)))) |
296 | 286 |
297 (defact link-to-elisp-doc (func-symbol) | 287 (defact link-to-elisp-doc (func-symbol) |
298 "Displays documentation for FUNC-SYMBOL." | 288 "Displays documentation for FUNC-SYMBOL." |
299 (interactive "aFunction to display doc for: ") | 289 (interactive "aFunction to display doc for: ") |
300 (cond ((not (symbolp func-symbol)) | 290 (cond ((not (symbolp func-symbol)) |
301 (hypb:error "(link-to-elisp-doc): `%s' not a symbol." | 291 (hypb:error "(link-to-elisp-doc): '%s' not a symbol." |
302 func-symbol)) | 292 func-symbol)) |
303 ((not (fboundp func-symbol)) | 293 ((not (fboundp func-symbol)) |
304 (hypb:error "(link-to-elisp-doc): `%s' not defined as a function." | 294 (hypb:error "(link-to-elisp-doc): '%s' not defined as a function." |
305 func-symbol)) | 295 func-symbol)) |
306 ((not (documentation func-symbol)) | 296 ((not (documentation func-symbol)) |
307 (hypb:error "(link-to-elisp-doc): `%s' has no documentation." | 297 (hypb:error "(link-to-elisp-doc): '%s' has no documentation." |
308 func-symbol)) | 298 func-symbol)) |
309 (t (let ((temp-buffer-show-function 'switch-to-buffer)) | 299 ((describe-function func-symbol)))) |
310 (hpath:display-buffer (current-buffer)) | |
311 (describe-function func-symbol))))) | |
312 | 300 |
313 (defact link-to-file (path &optional point) | 301 (defact link-to-file (path &optional point) |
314 "Displays file given by PATH scrolled to optional POINT. | 302 "Displays a PATH in another window scrolled to optional POINT. |
315 With POINT, buffer is displayed with POINT at window top." | 303 With POINT, buffer is displayed with POINT at the top of the window." |
316 (interactive | 304 (interactive |
317 (let ((prev-reading-p hargs:reading-p)) | 305 (let ((prev-reading-p hargs:reading-p)) |
318 (unwind-protect | 306 (unwind-protect |
319 (let* ((default (car defaults)) | 307 (let* ((default (car defaults)) |
320 (hargs:reading-p 'file) | 308 (hargs:reading-p 'file) |
329 (count-lines 1 (point)))) | 317 (count-lines 1 (point)))) |
330 (list path (point)) | 318 (list path (point)) |
331 (list path))) | 319 (list path))) |
332 (list path))) | 320 (list path))) |
333 (setq hargs:reading-p prev-reading-p)))) | 321 (setq hargs:reading-p prev-reading-p)))) |
334 (and (hpath:find path) | 322 (and (hpath:find-other-window path) |
335 (integerp point) | 323 (integerp point) |
336 (progn (goto-char (min (point-max) point)) | 324 (progn (goto-char (min (point-max) point)) |
337 (recenter 0)))) | 325 (recenter 0)))) |
338 | 326 |
339 (defact link-to-file-line (path line-num) | 327 (defact link-to-file-line (path line-num) |
340 "Displays a file given by PATH scrolled to LINE-NUM." | 328 "Displays a PATH in another window scrolled to LINE-NUM." |
341 (interactive "fPath to link to: \nnDisplay at line number: ") | 329 (interactive "fPath to link to: \nnDisplay at line number: ") |
342 (if (setq path (smart-tags-file-path path)) | 330 (and (setq path (smart-tags-file-path path)) |
343 (hpath:find-line path line-num))) | 331 (hpath:find-other-window path) |
332 (integerp line-num) | |
333 (progn (widen) | |
334 (goto-line line-num)))) | |
344 | 335 |
345 (defact link-to-Info-node (node) | 336 (defact link-to-Info-node (node) |
346 "Displays an Info NODE. | 337 "Displays an Info NODE in another window. |
347 NODE must be a string of the form `(file)nodename'." | 338 NODE must be a string of the form `(file)nodename'." |
348 (interactive "+IInfo (file)nodename to link to: ") | 339 (interactive "+IInfo (file)nodename to link to: ") |
349 (require 'info) | 340 (require 'info) |
350 (if (and (stringp node) (string-match "^(\\([^\)]+\\))\\(.*\\)" node)) | 341 (if (and (stringp node) (string-match "^(\\([^\)]+\\))\\(.*\\)" node)) |
351 (let ((nodename (substring node (match-beginning 2) (match-end 2))) | 342 (let ((nodename (substring node (match-beginning 2) (match-end 2))) |
355 Info-directory-list | 346 Info-directory-list |
356 Info-directory)))) | 347 Info-directory)))) |
357 (if (and file (setq file (hpath:substitute-value file))) | 348 (if (and file (setq file (hpath:substitute-value file))) |
358 (let ((wind (get-buffer-window "*info*"))) | 349 (let ((wind (get-buffer-window "*info*"))) |
359 (if wind (select-window wind) | 350 (if wind (select-window wind) |
360 (hpath:display-buffer (other-buffer))) | 351 (pop-to-buffer (other-buffer))) |
361 (info) (Info-goto-node (concat "(" file ")" nodename))) | 352 (info) (Info-goto-node (concat "(" file ")" nodename))) |
362 (hypb:error "(link-to-Info-node): Bad node spec: `%s'" node))))) | 353 (hypb:error "(link-to-Info-node): Bad node spec: '%s'" node))))) |
363 | 354 |
364 (defact link-to-kcell (file cell-ref) | 355 (defact link-to-kcell (file cell-ref) |
365 "Displays FILE with kcell given by CELL-REF at window top. | 356 "Displays FILE with kcell given by CELL-REF at the top of the window. |
366 See documentation for `kcell:ref-to-id' for valid cell-ref formats. | 357 See documentation for 'kcell:ref-to-id' for valid cell-ref formats. |
367 | 358 |
368 If FILE is nil, the current buffer is used. | 359 If FILE is nil, the current buffer is used. |
369 If CELL-REF is nil, the first cell in the view is shown." | 360 If CELL-REF is nil, the first cell in the view is shown." |
370 (interactive "fKotl file to link to: \n+KKcell to link to: ") | 361 (interactive "fKotl file to link to: \n+KKcell to link to: ") |
371 (require 'kfile) | 362 (require 'kfile) |
372 (cond ((and (stringp cell-ref) (> (length cell-ref) 0) | 363 (cond ((and (stringp cell-ref) (= ?| (aref cell-ref 0))) |
373 (= ?| (aref cell-ref 0))) | |
374 ;; Activate view spec in current window. | 364 ;; Activate view spec in current window. |
375 (kotl-mode:goto-cell cell-ref)) | 365 (kotl-mode:goto-cell cell-ref)) |
376 ((if file | 366 ((if file |
377 (hpath:find file) | 367 (hpath:find-other-window file) |
378 (hpath:display-buffer (current-buffer))) | 368 (pop-to-buffer (current-buffer) t)) |
379 (if cell-ref | 369 (if cell-ref |
380 (kotl-mode:goto-cell cell-ref) | 370 (kotl-mode:goto-cell cell-ref) |
381 (kotl-mode:beginning-of-buffer)) | 371 (kotl-mode:beginning-of-buffer)) |
382 (recenter 0)))) | 372 (recenter 0)))) |
383 | 373 |
384 (defact link-to-mail (mail-msg-id &optional mail-file) | 374 (defact link-to-mail (mail-msg-id &optional mail-file) |
385 "Displays mail msg with MAIL-MSG-ID from optional MAIL-FILE. | 375 "Displays mail msg with MAIL-MSG-ID from optional MAIL-FILE in other window. |
386 See documentation for the variable `hmail:init-function' for information on | 376 See documentation for the variable 'hmail:init-function' for information on |
387 how to specify a mail reader to use." | 377 how to specify a mail reader to use." |
388 (interactive "+MMail Msg: ") | 378 (interactive "+MMail Msg: ") |
389 (if (not (fboundp 'rmail:msg-to-p)) | 379 (if (not (fboundp 'rmail:msg-to-p)) |
390 (hypb:error "(link-to-mail): Invoke mail reader before trying to follow a mail link.") | 380 (hypb:error "(link-to-mail): Invoke mail reader before trying to follow a mail link.") |
391 (if (and (listp mail-msg-id) (null mail-file)) | 381 (if (and (listp mail-msg-id) (null mail-file)) |
392 (setq mail-file (car (cdr mail-msg-id)) | 382 (setq mail-file (car (cdr mail-msg-id)) |
393 mail-msg-id (car mail-msg-id))) | 383 mail-msg-id (car mail-msg-id))) |
394 (let ((wconfig (current-window-configuration))) | 384 (let ((wind (selected-window)) |
395 (hpath:display-buffer (current-buffer)) | 385 (wconfig (current-window-configuration))) |
386 (other-window 1) | |
387 (if (eq wind (selected-window)) | |
388 (progn (split-window-vertically nil) (other-window 1))) | |
396 ;; Initialize user-specified mail reader if need be. | 389 ;; Initialize user-specified mail reader if need be. |
397 (if (and (symbolp hmail:init-function) | 390 (if (and (symbolp hmail:init-function) |
398 (fboundp hmail:init-function) | 391 (fboundp hmail:init-function) |
399 (listp (symbol-function hmail:init-function)) | 392 (listp (symbol-function hmail:init-function)) |
400 (eq 'autoload (car (symbol-function hmail:init-function)))) | 393 (eq 'autoload (car (symbol-function hmail:init-function)))) |
401 (funcall hmail:init-function)) | 394 (funcall hmail:init-function)) |
402 (if (rmail:msg-to-p mail-msg-id mail-file) | 395 (if (rmail:msg-to-p mail-msg-id mail-file) |
403 nil | 396 nil |
404 ;; Couldn't find message, restore old window config, report error | 397 ;; Couldn't find message, restore old window config, report error |
405 (set-window-configuration wconfig) | 398 (set-window-configuration wconfig) |
406 (hypb:error "(link-to-mail): No msg `%s' in file \"%s\"." | 399 (hypb:error "(link-to-mail): No msg '%s' in file \"%s\"." |
407 mail-msg-id mail-file))))) | 400 mail-msg-id mail-file))))) |
408 | 401 |
409 (defact link-to-regexp-match (regexp n source &optional buffer-p) | 402 (defact link-to-regexp-match (regexp n source &optional buffer-p) |
410 "Finds REGEXP's Nth occurrence in SOURCE and displays location at window top. | 403 "Finds REGEXP's Nth occurrence in SOURCE and displays location at window top. |
411 SOURCE is a pathname unless optional BUFFER-P is non-nil, then SOURCE must be | 404 SOURCE is a pathname unless optional BUFFER-P is non-nil, then SOURCE must be |
417 (if (stringp source) | 410 (if (stringp source) |
418 (setq source (get-buffer source))) | 411 (setq source (get-buffer source))) |
419 ;; Source is a pathname. | 412 ;; Source is a pathname. |
420 (if (not (stringp source)) | 413 (if (not (stringp source)) |
421 (hypb:error | 414 (hypb:error |
422 "(link-to-regexp-match): Source parameter is not a filename: `%s'" | 415 "(link-to-regexp-match): Source parameter is not a filename: '%s'" |
423 orig-src) | 416 orig-src) |
424 (setq source (find-file-noselect (hpath:substitute-value source))))) | 417 (setq source (find-file-noselect (hpath:substitute-value source))))) |
425 (if (not (bufferp source)) | 418 (if (not (bufferp source)) |
426 (hypb:error | 419 (hypb:error |
427 "(link-to-regexp-match): Invalid source parameter: `%s'" orig-src) | 420 "(link-to-regexp-match): Invalid source parameter: '%s'" orig-src) |
428 (hpath:display-buffer source) | 421 (switch-to-buffer-other-window source) |
429 (widen) | 422 (widen) |
430 (goto-char (point-min)) | 423 (goto-char (point-min)) |
431 (if (re-search-forward regexp nil t n) | 424 (if (re-search-forward regexp nil t n) |
432 (progn (beginning-of-line) (recenter 0) t) | 425 (progn (beginning-of-line) (recenter 0) t) |
433 (hypb:error | 426 (hypb:error |
434 "(link-to-regexp-match): Pattern not found: `%s'" regexp))))) | 427 "(link-to-regexp-match): Pattern not found: '%s'" regexp))))) |
435 | 428 |
436 (defact link-to-rfc (rfc-num) | 429 (defact link-to-rfc (rfc-num) |
437 "Retrieves and displays an Internet rfc given by RFC-NUM. | 430 "Retrieves and displays an Internet rfc given by RFC-NUM. |
438 RFC-NUM may be a string or an integer. Requires ange-ftp or efs for | 431 RFC-NUM may be a string or an integer. Requires ange-ftp or efs for |
439 remote retrievals." | 432 remote retrievals." |
440 (interactive "nRFC number to retrieve: ") | 433 (interactive "nRFC number to retrieve: ") |
441 (if (or (stringp rfc-num) (integerp rfc-num)) | 434 (if (or (stringp rfc-num) (integerp rfc-num)) |
442 (hpath:find (hpath:rfc rfc-num)))) | 435 (hpath:find-other-window (hpath:rfc rfc-num)))) |
443 | 436 |
444 (defact link-to-string-match (string n source &optional buffer-p) | 437 (defact link-to-string-match (string n source &optional buffer-p) |
445 "Finds STRING's Nth occurrence in SOURCE and displays location at window top. | 438 "Finds STRING's Nth occurrence in SOURCE and displays location at window top. |
446 SOURCE is a pathname unless optional BUFFER-P is non-nil, then SOURCE must be | 439 SOURCE is a pathname unless optional BUFFER-P is non-nil, then SOURCE must be |
447 a buffer name or buffer. | 440 a buffer name or buffer. |
449 (interactive "sString to match: \nnOccurrence number: \nfFile to search: ") | 442 (interactive "sString to match: \nnOccurrence number: \nfFile to search: ") |
450 (funcall (actype:action 'link-to-regexp-match) | 443 (funcall (actype:action 'link-to-regexp-match) |
451 (regexp-quote string) n source buffer-p)) | 444 (regexp-quote string) n source buffer-p)) |
452 | 445 |
453 (defact man-show (topic) | 446 (defact man-show (topic) |
454 "Displays man page on TOPIC, which may be of the form <command>(<section>). | 447 "Displays man page on TOPIC, which may be of the form <command>(<section>)." |
455 If using the Superman manual entry package, see the documentation for | |
456 `sm-notify' to control where the man page is displayed." | |
457 (interactive "sManual topic: ") | 448 (interactive "sManual topic: ") |
458 (let ((display-buffer-function | 449 (manual-entry topic)) |
459 (function (lambda (buffer &rest unused) (hpath:display-buffer buffer))))) | |
460 (manual-entry topic))) | |
461 | 450 |
462 (defact rfc-toc (&optional buf-name opoint) | 451 (defact rfc-toc (&optional buf-name opoint) |
463 "Computes and displays summary of an Internet rfc in BUF-NAME. | 452 "Computes and displays summary of an Internet rfc in BUF-NAME. |
464 Assumes point has already been moved to start of region to summarize. | 453 Assumes point has already been moved to start of region to summarize. |
465 Optional OPOINT is point to return to in BUF-NAME after displaying summary." | 454 Optional OPOINT is point to return to in BUF-NAME after displaying summary." |
471 (if buf | 460 (if buf |
472 (progn (switch-to-buffer (setq buf-name buf)) | 461 (progn (switch-to-buffer (setq buf-name buf)) |
473 t)))) | 462 t)))) |
474 (t (if opoint (goto-char opoint)) | 463 (t (if opoint (goto-char opoint)) |
475 (hypb:error "(rfc-toc): Invalid buffer name: %s" buf-name)))) | 464 (hypb:error "(rfc-toc): Invalid buffer name: %s" buf-name)))) |
476 (let ((sect-regexp "^[ \t]*[1-9][0-9]*\\.[0-9.]*[ \t]+[^ \t\n]") | 465 (let ((sect-regexp "^[ \t]*[1-9][0-9]*\\.[0-9.]*[ \t]+[^ \t\n]")) |
477 (temp-buffer-show-function 'switch-to-buffer)) | |
478 (hpath:display-buffer (current-buffer)) | |
479 (occur sect-regexp) | 466 (occur sect-regexp) |
480 (set-buffer "*Occur*") | 467 (set-buffer "*Occur*") |
481 (rename-buffer (format "*%s toc*" buf-name)) | 468 (rename-buffer (format "*%s toc*" buf-name)) |
482 (re-search-forward "^[ ]*[0-9]+:" nil t) | 469 (re-search-forward "^[ ]*[0-9]+:" nil t) |
483 (beginning-of-line) | 470 (beginning-of-line) |