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