annotate lisp/hyperbole/hactypes.el @ 0:376386a54a3c r19-14

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