1 ;;; hrmail.el --- Support for Hyperbole buttons in mail reader: Rmail.
3 ;; Copyright (C) 1991-1995 Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: hypermedia, mail
10 ;; This file is part of GNU Hyperbole.
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
17 ;; GNU Hyperbole is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; Automatically configured for use in "hyperbole.el".
30 ;; If hsite loading fails prior to initializing Hyperbole Rmail support,
32 ;; {M-x Rmail-init RTN}
40 ;;; Other required Elisp libraries
59 "Initializes Hyperbole support for Rmail mail reading."
61 (setq hmail:composer 'mail-mode
62 hmail:lister 'rmail-summary-mode
63 hmail:modifier 'rmail-edit-mode
64 hmail:reader 'rmail-mode)
65 (var:append 'rmail-show-message-hook '(hmail:msg-narrow))
68 ;; Setup public abstract interface to Hyperbole defined mail
69 ;; reader-specific functions used in "hmail.el".
73 ;; Setup private abstract interface to mail reader-specific functions
74 ;; used in "hmail.el".
76 (fset 'rmail:get-new 'rmail-get-new-mail)
77 (fset 'rmail:msg-forward 'rmail-forward)
78 (fset 'rmail:summ-msg-to 'rmail-summary-goto-msg)
79 (fset 'rmail:summ-new 'rmail-new-summary)
81 (message "Hyperbole RMAIL mail reader support initialized."))
84 (defun Rmail-msg-hdrs-full (toggled)
85 "If TOGGLED is non-nil, toggle full/hidden headers, else show full headers."
91 (rmail-maybe-set-message-counters)
92 (narrow-to-region (rmail-msgbeg rmail-current-message)
94 (let ((buffer-read-only nil))
95 (goto-char (point-min))
97 ;; Need to show full header
98 (if (= (following-char) ?1)
101 (progn (rmail-toggle-header)
105 (defun Rmail-msg-narrow ()
106 "Narrows mail reader buffer to current message.
107 This includes Hyperbole button data."
108 (let ((beg (rmail-msgbeg rmail-current-message))
109 (end (rmail-msgend rmail-current-message)))
110 (narrow-to-region beg end)))
112 (defun Rmail-msg-next () (rmail-next-undeleted-message 1))
114 (defun Rmail-msg-num ()
115 "Returns number of Rmail message that point is within."
117 (let ((count 0) opoint)
119 (while (and (not (eobp))
120 (progn (setq opoint (point))
121 (re-search-backward "^\^_" nil t)))
122 (if (= opoint (point))
124 (setq count (1+ count)))))
127 (defun Rmail-msg-prev () (rmail-previous-undeleted-message 1))
129 (defun Rmail-msg-to-p (mail-msg-id mail-file)
130 "Sets current buffer to start of msg with MAIL-MSG-ID in MAIL-FILE.
131 Returns t if successful, else nil."
132 (if (not (file-readable-p mail-file))
134 (let ((buf (get-file-buffer mail-file)))
136 (switch-to-buffer buf)
137 (or (eq major-mode 'rmail-mode)
139 (t (rmail mail-file))))
142 (if (re-search-forward (concat rmail:msg-hdr-prefix
143 (regexp-quote mail-msg-id)) nil t)
144 ;; Found matching msg
146 (setq buffer-read-only t)
147 (rmail-show-message (Rmail-msg-num))
151 (defun Rmail-msg-widen ()
152 "Widens buffer to full current message including Hyperbole button data."
153 (let ((start (point-min))
158 (if (re-search-forward "^\^_" nil t)
159 (progn (forward-char -1)
160 (setq end (point)))))
161 (narrow-to-region start end))))
164 "Sets current buffer to a mail reader buffer."
165 (and (eq major-mode 'rmail-summary-mode) (set-buffer rmail-buffer)))
167 (fset 'Rmail-Summ-delete 'rmail-summary-delete-forward)
169 (fset 'Rmail-Summ-expunge 'rmail-summary-expunge)
171 (fset 'Rmail-Summ-goto 'rmail-summary-goto-msg)
173 (defun Rmail-Summ-to ()
174 "Sets current buffer to a mail listing buffer."
175 (and (eq major-mode 'rmail-mode) (set-buffer rmail-summary-buffer)))
177 (fset 'Rmail-Summ-undelete-all 'rmail-summary-undelete-many)
180 ;;; Private functions
184 ;;; Overlay version of this function from "rmailedit.el" to include any
185 ;;; hidden Hyperbole button data when computing message length.
186 (defun rmail-cease-edit ()
187 "Finish editing message; switch back to Rmail proper."
189 ;; Make sure buffer ends with a newline.
192 (goto-char (point-max))
193 (if (/= (preceding-char) ?\n)
195 ;; Adjust the marker that points to the end of this message.
196 (set-marker (aref rmail-message-vector (1+ rmail-current-message))
200 (let ((old rmail-old-text))
201 ;; Update the mode line.
202 (set-buffer-modified-p (buffer-modified-p))
204 (if (and (= (length old) (- (point-max) (point-min)))
205 (string= old (buffer-substring (point-min) (point-max))))
208 (rmail-set-attribute "edited" t)
209 (if (boundp 'rmail-summary-vector)
211 (aset rmail-summary-vector (1- rmail-current-message) nil)
213 (rmail-widen-to-current-msgbeg
216 (if (looking-at "Summary-line: ")
217 (let ((buffer-read-only nil))
218 (delete-region (point)
219 (progn (forward-line 1)
221 (rmail-show-message))))))
222 (setq buffer-read-only t))
225 ;;; Overlay version of this function from "rmail.el" to include any
226 ;;; Hyperbole button data.
227 (defun rmail-forward (&optional resend)
228 "Forward the current message to another user."
230 ;; Resend argument is ignored but for now but is there for Emacs V19 call
232 ;;>> this gets set even if we abort. Can't do anything about it, though.
233 (rmail-set-attribute "forwarded" t)
234 (let ((forward-buffer (current-buffer))
236 (mail-strip-quoted-names (mail-fetch-field "From"))
237 ": " (or (mail-fetch-field "Subject") "") "]")))
240 ;; If only one window, use it for the mail buffer.
241 ;; Otherwise, use another window for the mail buffer
242 ;; so that the Rmail buffer remains visible
243 ;; and sending the mail will get back to it.
244 (if (if (one-window-p t)
245 (mail nil nil subject)
246 (mail-other-window nil nil subject))
248 (goto-char (point-max))
250 (insert-buffer forward-buffer)
254 ;;; Overlay version of 'rmail-get-new-mail' from "rmail.el" to highlight
255 ;;; Hyperbole buttons when possible.
257 (hypb:function-overload 'rmail-get-new-mail nil
258 '(if (fboundp 'hproperty:but-create)
259 (progn (widen) (hproperty:but-create)
260 (rmail-show-message))))
262 ;;; Overlay version of 'rmail-new-summary' from "rmailsum.el" to
263 ;;; highlight Hyperbole buttons when possible.
265 (or (fboundp 'rmail-new-summary) (load "rmailsum"))
266 (hypb:function-overload 'rmail-new-summary nil
267 '(if (fboundp 'hproperty:but-create)
268 (hproperty:but-create)))
271 ;;; Private variables
276 ;;; hrmail.el ends here