annotate lisp/hyperbole/hmail.el @ 39:06f275776fba

Added tag r19-15b102 for changeset 1a767b41a199
author cvs
date Mon, 13 Aug 2007 08:54:02 +0200
parents 4103f0995bd7
children 131b0175ea99
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: hmail.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Support for Hyperbole buttons embedded in e-mail messages.
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: hypermedia, mail
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: 9-Oct-91 at 18:38:05
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
12 ;; LAST-MOD: 6-Dec-96 at 12:35:29 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This file is part of Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; Copyright (C) 1991-1995, Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; Developed with support from Motorola Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; The 'hmail' class provides an abstract interface for connecting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; GNU Emacs-based mail readers and composers to Hyperbole. Its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; public variables together with supporting classes determine the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; mail tools that Hyperbole will support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; The 'rmail' and 'lmail' classes provide a set of feature names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; that Hyperbole packages can call to interface to a user's selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; mail reader. Eventually, a full abstract calling interface may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; developed. The public features (the ones above the line of dashes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; must be redefined for any mail reader. The private features are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; used only by a particular mail reader.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; The 'smail' class is similar; it connects a mail composer for use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; with Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar hnews:composer 'news-reply-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "Major mode for composing USENET news to be sent with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar hnews:lister 'gnus-summary-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "Major mode for listing USENET news header summaries with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar hnews:reader 'gnus-article-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "Major mode for reading USENET news with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvar hmail:init-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "*Function (a symbol) to run to initialize Hyperbole support for a mail reader/composer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Valid values are: nil, Rmail-init, Vm-init, Mh-init, or Pm-init.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defvar hmail:composer 'mail-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "Major mode for composing mail to be sent with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar hmail:lister nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 "Major mode for listing mail header summaries with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar hmail:modifier nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Major mode for editing received mail with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defvar hmail:reader nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Major mode for reading mail with Hyperbole buttons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; ========================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; hmail class - abstract
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; ========================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun hmail:hbdata-start (&optional msg-start msg-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Returns point immediately before any Hyperbole button data in current msg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Returns message end point when no button data is found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Has side-effect of widening buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Message's displayable part begins at optional MSG-START and ends at or before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 MSG-END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (or msg-end (setq msg-end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (goto-char msg-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (if (search-backward hmail:hbdata-sep msg-start t) (1- (point)) msg-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defun hmail:hbdata-to-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "Moves point to Hyperbole but data start in an e-mail msg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Returns t if button data is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (and (cond ((memq major-mode (list hmail:reader hmail:modifier))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (rmail:msg-narrow) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ((or (hmail:lister-p) (hnews:lister-p)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ((memq major-mode (list hmail:composer hnews:reader
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 hnews:composer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (widen) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (search-backward hmail:hbdata-sep nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (progn (forward-line 1) t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defun hmail:browser-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 "Returns t iff current major mode helps browse received e-mail messages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (memq major-mode (list hmail:reader hmail:lister)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun hmail:buffer (&optional buf invisible-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Start composing mail with the contents of optional BUF as the message body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Invisible text is expanded and included in the mail only if INVISIBLE-FLAG is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 non-nil. BUF defaults to the current buffer and may be a buffer or buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (interactive (list (current-buffer) (y-or-n-p "Include invisible text? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (or buf (setq buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (stringp buf) (setq buf (get-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (hmail:region (point-min) (point-max) buf invisible-flag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defun hmail:compose (address expr &optional subject help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "Compose mail with ADDRESS and evaluation of EXPR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Optional SUBJECT and HELP message may also be given."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (interactive "sDeliver e-mail to: \nSubject: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (require 'hactypes) ;; Needed in case EXPR calls 'hact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (if (or (stringp help) (stringp subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq subject "Be explicit here. Make a statement or ask a question."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (hmail:invoke address nil subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (eval expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (re-search-backward "^Subject: " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (message (if (stringp help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "Replace subject, compose message, and then mail.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defun hmail:composing-dir (key-src)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "If button KEY-SRC is a mail/news composure buffer, returns composure directory, else nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (and (bufferp key-src)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (progn (set-buffer key-src)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (or (eq major-mode hmail:composer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (eq major-mode hnews:composer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defun hmail:editor-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "Returns t iff current major mode edits Hyperbole e-mail/news messages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (memq major-mode (list hmail:composer hnews:composer hmail:modifier)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (defun hmail:init (class-prefix func-suffix-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "Sets up CLASS-PREFIX functions with aliases for FUNC-SUFFIX-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 'hmail:reader' should be set appropriately before this is called."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if (null hmail:reader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let* ((reader-name (symbol-name hmail:reader))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (reader-prefix (capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (substring reader-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 0 (string-match "-" reader-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 hmail-func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (lambda (func-suffix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq hmail-func (hypb:replace-match-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "Summ-" func-suffix "" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (fset (intern (concat class-prefix hmail-func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (intern (concat reader-prefix "-" func-suffix)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 func-suffix-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun hmail:invoke (&optional address cc subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "Invoke user preferred mail composer: vm-mail, mh-send or mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Optional arguments are ADDRESS, CC list and SUBJECT of mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (or address (setq address ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (or cc (setq cc ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (or subject (setq subject ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (cond ((and (featurep 'vm) (fboundp 'vm-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (vm-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (insert address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (cond ((re-search-forward "^CC: " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (insert cc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ((not (equal cc ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (insert "CC: " cc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (if (re-search-forward "^Subject: " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (progn (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (insert subject)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ((and (featurep 'mh-e) (fboundp 'mh-send))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (mh-send address cc subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; Next 3 lines prevent blank lines between fields due to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; fill-region-as-paragraph within mail-setup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (if (equal address "") (setq address nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (if (equal cc "") (setq cc nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (equal subject "") (setq subject nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (mail nil address subject nil cc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun hmail:lister-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Returns t iff current major mode is a Hyperbole e-mail lister mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (eq major-mode hmail:lister))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun hnews:lister-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Returns t iff current major mode is a Hyperbole news summary lister mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (eq major-mode hnews:lister))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defun hmail:mode-is-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "Returns current major mode if a Hyperbole e-mail or news mode, else nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (car (memq major-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (list hmail:reader hmail:composer hmail:lister hmail:modifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 hnews:reader hnews:composer hnews:lister)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun hmail:msg-narrow (&optional msg-start msg-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "Narrows buffer to displayable part of current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 Its displayable part begins at optional MSG-START and ends at or before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 MSG-END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (if (hmail:reader-p) (rmail:msg-widen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setq msg-start (or msg-start (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 msg-end (or msg-end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (narrow-to-region msg-start (hmail:hbdata-start msg-start msg-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defun hmail:reader-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 "Returns t iff current major mode shows received Hyperbole e-mail messages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (memq major-mode (list hmail:reader hmail:modifier)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defun hmail:region (start end &optional buf invisible-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Start composing mail with region between START and END included in message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 Invisible text is expanded and included in the mail only if INVISIBLE-FLAG is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 non-nil. Optional BUF contains the region and defaults to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 buffer. It may be a buffer or buffer name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (interactive (list (region-beginning) (region-end) (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (y-or-n-p "Include invisible text? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (or buf (setq buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if (stringp buf) (setq buf (get-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (let (mail-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (hmail:invoke)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq mail-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if (search-forward mail-header-separator nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; Within header, so move to body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (hypb:insert-region mail-buf start end invisible-flag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; ========================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;; rmail class - mail reader interface - abstract
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; ========================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun rmail:init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Initializes Hyperbole abstract mail interface for a particular mail reader.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 'hmail:reader' should be set appropriately before this is called."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (hmail:init "rmail:" '("msg-hdrs-full" "msg-narrow" "msg-num"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "msg-prev" "msg-next"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "msg-to-p" ;; 2 args: (mail-msg-id mail-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "msg-widen" "to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (hmail:init "lmail:" '("Summ-delete" "Summ-expunge" "Summ-goto" "Summ-to"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "Summ-undelete-all")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defvar rmail:msg-hdr-prefix "\\(^Date: \\|\n\nFrom [^ \n]+ \\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "String header preceding an e-mail received message-id.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defun rmail:msg-id-get ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "Returns current msg id for an 'hmail:reader' buffer as a string, else nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Signals error when current mail reader is not supported."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (let* ((reader (symbol-name hmail:reader))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; (toggled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (or (fboundp 'rmail:msg-hdrs-full)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (error "(rmail:msg-id-get): Invalid mail reader: %s" reader))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; (setq toggled (rmail:msg-hdrs-full nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if (re-search-forward (concat rmail:msg-hdr-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "\\(.+\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; Found matching msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (buffer-substring (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; (rmail:msg-hdrs-full toggled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;; ------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;; Each mail reader-specific Hyperbole support module must also define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;;; the following functions, commonly aliased to existing mail reader
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;; functions within the "-init" function of the Hyperbole module.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;; See "hrmail.el" for examples.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;;; rmail:get-new, rmail:msg-forward, rmail:summ-msg-to, rmail:summ-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defvar hmail:hbdata-sep "\^Lbd"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "Text separating e-mail msg from any trailing Hyperbole button data.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (provide 'hmail)