" (line-end-position) t)
(progn
(forward-char -2)
(speedbar-do-function-pointer)))))
(defun rmail-speedbar-move-message (_text token _indent)
"From button TEXT, copy current message to the rmail file specified by TOKEN.
TEXT and INDENT are not used."
(dframe-with-attached-buffer
(message "Moving message to %s" token)
;; expand-file-name is needed due to the unhelpful way in which
;; rmail-output expands non-absolute filenames against rmail-default-file.
;; What is the point of that, anyway?
(rmail-output (expand-file-name token))))
;; Functions for setting, getting and encoding the POP password.
;; The password is encoded to prevent it from being easily accessible
;; to "prying eyes." Obviously, this encoding isn't "real security,"
;; nor is it meant to be.
;;;###autoload
(defun rmail-set-remote-password (password)
"Set PASSWORD to be used for retrieving mail from a POP or IMAP server."
(interactive "sPassword: ")
(if password
(setq rmail-encoded-remote-password
(rmail-encode-string password (emacs-pid)))
(setq rmail-remote-password nil)
(setq rmail-encoded-remote-password nil)))
(defun rmail-get-remote-password (imap)
"Get the password for retrieving mail from a POP or IMAP server. If none
has been set, then prompt the user for one."
(when (not rmail-encoded-remote-password)
(if (not rmail-remote-password)
(setq rmail-remote-password
(read-passwd (if imap
"IMAP password: "
"POP password: "))))
(rmail-set-remote-password rmail-remote-password)
(setq rmail-remote-password nil))
(rmail-encode-string rmail-encoded-remote-password (emacs-pid)))
(defun rmail-have-password ()
(or rmail-remote-password rmail-encoded-remote-password))
(defun rmail-encode-string (string mask)
"Encode STRING with integer MASK, by taking the exclusive OR of the
lowest byte in the mask with the first character of string, the
second-lowest-byte with the second character of the string, etc.,
restarting at the lowest byte of the mask whenever it runs out.
Returns the encoded string. Calling the function again with an
encoded string (and the same mask) will decode the string."
(setq mask (abs mask)) ; doesn't work if negative
(let* ((string-vector (string-to-vector string)) (i 0)
(len (length string-vector)) (curmask mask) charmask)
(while (< i len)
(if (= curmask 0)
(setq curmask mask))
(setq charmask (% curmask 256))
(setq curmask (lsh curmask -8))
(aset string-vector i (logxor charmask (aref string-vector i)))
(setq i (1+ i)))
(concat string-vector)))
(defun rmail-epa-decrypt-1 (mime)
"Decrypt a single GnuPG encrypted text in a message.
The starting string of the encrypted text should have just been regexp-matched.
Argument MIME is non-nil if this is a mime message."
(let* ((armor-start (match-beginning 0))
(armor-prefix (buffer-substring
(line-beginning-position)
armor-start))
(armor-end-regexp)
armor-end after-end
unquote)
(if (string-match "\\'" armor-prefix)
(setq armor-prefix ""))
(setq armor-end-regexp
(concat "^"
armor-prefix
"-----END PGP MESSAGE-----$"))
(setq armor-end (re-search-forward armor-end-regexp
nil t))
(unless armor-end
(error "Encryption armor beginning has no matching end"))
(goto-char armor-start)
;; Because epa--find-coding-system-for-mime-charset not autoloaded.
(require 'epa)
;; Advance over this armor.
(goto-char armor-end)
(setq after-end (- (point-max) armor-end))
(when mime
(save-excursion
(goto-char armor-start)
(re-search-backward "^--" nil t)
(save-restriction
(narrow-to-region (point) armor-start)
;; Use the charset specified in the armor.
(unless coding-system-for-read
(if (re-search-forward "^[ \t]*Charset[ \t\n]*:[ \t\n]*\\(.*\\)" nil t)
(setq coding-system-for-read
(epa--find-coding-system-for-mime-charset
(intern (downcase (match-string 1)))))))
(goto-char (point-min))
(if (re-search-forward "^[ \t]*Content-transfer-encoding[ \t\n]*:[ \t\n]*quoted-printable[ \t]*$" nil t)
(setq unquote t)))))
(when unquote
(let ((inhibit-read-only t))
(mail-unquote-printable-region armor-start
(- (point-max) after-end))))
;; Decrypt it, maybe in place, maybe making new buffer.
(epa-decrypt-region
armor-start (- (point-max) after-end)
;; Call back this function to prepare the output.
(lambda ()
(let ((inhibit-read-only t))
(delete-region armor-start (- (point-max) after-end))
(goto-char armor-start)
(current-buffer))))
(list armor-start (- (point-max) after-end) mime
armor-end-regexp)))
;; Should this have a key-binding, or be in a menu?
;; There doesn't really seem to be an appropriate menu.
;; Eg the edit command is not in a menu either.
(defun rmail-epa-decrypt ()
"Decrypt GnuPG or OpenPGP armors in current message."
(interactive)
;; Save the current buffer here for cleanliness, in case we
;; change it in one of the calls to `epa-decrypt-region'.
(save-excursion
(let (decrypts (mime (rmail-mime-message-p))
mime-disabled)
(goto-char (point-min))
;; Turn off mime processing.
(when (and mime
(not (get-text-property (point-min) 'rmail-mime-hidden)))
(setq mime-disabled t)
(rmail-mime))
;; Now find all armored messages in the buffer
;; and decrypt them one by one.
(goto-char (point-min))
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(let ((coding-system-for-read coding-system-for-read)
(case-fold-search t))
(push (rmail-epa-decrypt-1 mime) decrypts)))
(when (and decrypts (eq major-mode 'rmail-mode))
(rmail-add-label "decrypt"))
(when (and decrypts (rmail-buffers-swapped-p))
(when (y-or-n-p "Replace the original message? ")
(setq decrypts (nreverse decrypts))
(let ((beg (rmail-msgbeg rmail-current-message))
(end (rmail-msgend rmail-current-message))
(from-buffer (current-buffer)))
(with-current-buffer rmail-view-buffer
(narrow-to-region beg end)
(goto-char (point-min))
(dolist (d decrypts)
;; Find, in the real Rmail buffer, the same armors
;; that we found and decrypted in the view buffer.
(if (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(let (armor-start armor-end armor-end-regexp)
(setq armor-start (match-beginning 0)
armor-end-regexp (nth 3 d)
armor-end (re-search-forward
armor-end-regexp
nil t))
;; Found as expected -- now replace it with the decrypt.
(when armor-end
(delete-region armor-start armor-end)
(insert-buffer-substring from-buffer (nth 0 d) (nth 1 d)))
;; Change the mime type (if this is in a mime part)
;; so this part will display by default
;; when the message is shown later.
(when (nth 2 d)
(goto-char armor-start)
(when (re-search-backward "^--" nil t)
(save-restriction
(narrow-to-region (point) armor-start)
(when (re-search-forward "^content-type[ \t\n]*:[ \t\n]*" nil t)
(when (looking-at "[^\n \t;]+")
(let ((value (match-string 0)))
(unless (member value '("text/plain" "text/html"))
(replace-match "text/plain"))))))))
)))))))
(when (and (null decrypts)
mime mime-disabled)
;; Re-enable mime processing.
(rmail-mime)
;; Find each Show button and show that part.
(while (search-forward " Show " nil t)
(forward-char -2)
(let ((rmail-mime-render-html-function nil)
(entity (get-text-property (point) 'rmail-mime-entity)))
(unless (and (not (stringp entity))
(rmail-mime-entity-truncated entity))
(push-button))))
(goto-char (point-min))
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(let ((coding-system-for-read coding-system-for-read)
(case-fold-search t))
(push (rmail-epa-decrypt-1 mime) decrypts)))
)
(unless decrypts
(error "Nothing to decrypt")))))
;;;; Desktop support
(defun rmail-restore-desktop-buffer (file-name
_buffer-name
_buffer-misc)
"Restore an rmail buffer specified in a desktop file."
(condition-case nil
(progn
(rmail-input file-name)
(if (eq major-mode 'rmail-mode)
(current-buffer)
rmail-buffer))
(file-locked
(kill-buffer (current-buffer))
nil)))
(add-to-list 'desktop-buffer-mode-handlers
'(rmail-mode . rmail-restore-desktop-buffer))
;; We use this to record the encoding of the current message before
;; saving the message collection.
(defvar rmail-message-encoding nil)
;; Used in `write-region-annotate-functions' to write rmail files.
(defun rmail-write-region-annotate (start _end)
(when (and (null start) rmail-buffer-swapped)
(unless (buffer-live-p rmail-view-buffer)
(error "Buffer `%s' with real text of `%s' has disappeared"
(buffer-name rmail-view-buffer)
(buffer-name (current-buffer))))
(setq rmail-message-encoding buffer-file-coding-system)
(set-buffer rmail-view-buffer)
(widen)
nil))
;; Used to restore the encoding of the buffer where we show the
;; current message, after we save the message collection. This is
;; needed because rmail-write-region-annotate switches buffers behind
;; save-file's back, with the side effect that last-coding-system-used
;; is assigned to buffer-file-coding-system of the wrong buffer.
(defun rmail-after-save-hook ()
(if (or (eq rmail-view-buffer (current-buffer))
(eq rmail-buffer (current-buffer)))
(with-current-buffer
(if (rmail-buffers-swapped-p) rmail-buffer rmail-view-buffer)
(setq buffer-file-coding-system rmail-message-encoding))))
(add-hook 'after-save-hook 'rmail-after-save-hook)
;;; Start of automatically extracted autoloads.
;;;### (autoloads nil "rmailedit" "rmailedit.el" "1ed1c211e6e9c254ba3e0dd8d546e745")
;;; Generated autoloads from rmailedit.el
(autoload 'rmail-edit-current-message "rmailedit" "\
Edit the contents of this message.
\(fn)" t nil)
;;;***
;;;### (autoloads nil "rmailkwd" "rmailkwd.el" "298dcda7febb6e4ebf0a166101f40650")
;;; Generated autoloads from rmailkwd.el
(autoload 'rmail-add-label "rmailkwd" "\
Add LABEL to labels associated with current RMAIL message.
Completes (see `rmail-read-label') over known labels when reading.
LABEL may be a symbol or string. Only one label is allowed.
\(fn LABEL)" t nil)
(autoload 'rmail-kill-label "rmailkwd" "\
Remove LABEL from labels associated with current RMAIL message.
Completes (see `rmail-read-label') over known labels when reading.
LABEL may be a symbol or string. Only one label is allowed.
\(fn LABEL)" t nil)
(autoload 'rmail-read-label "rmailkwd" "\
Read a label with completion, prompting with PROMPT.
Completions are chosen from `rmail-label-obarray'. The default
is `rmail-last-label', if that is non-nil. Updates `rmail-last-label'
according to the choice made, and returns a symbol.
\(fn PROMPT)" nil nil)
(autoload 'rmail-previous-labeled-message "rmailkwd" "\
Show previous message with one of the labels LABELS.
LABELS should be a comma-separated list of label names.
If LABELS is empty, the last set of labels specified is used.
With prefix argument N moves backward N messages with these labels.
\(fn N LABELS)" t nil)
(autoload 'rmail-next-labeled-message "rmailkwd" "\
Show next message with one of the labels LABELS.
LABELS should be a comma-separated list of label names.
If LABELS is empty, the last set of labels specified is used.
With prefix argument N moves forward N messages with these labels.
\(fn N LABELS)" t nil)
;;;***
;;;### (autoloads nil "rmailmm" "rmailmm.el" "36f518e036612a33eb436cb267fd39c7")
;;; Generated autoloads from rmailmm.el
(autoload 'rmail-mime "rmailmm" "\
Toggle the display of a MIME message.
The actual behavior depends on the value of `rmail-enable-mime'.
If `rmail-enable-mime' is non-nil (the default), this command toggles
the display of a MIME message between decoded presentation form and
raw data. With optional prefix argument ARG, it toggles the display only
of the MIME entity at point, if there is one. The optional argument
STATE forces a particular display state, rather than toggling.
`raw' forces raw mode, any other non-nil value forces decoded mode.
If `rmail-enable-mime' is nil, this creates a temporary \"*RMAIL*\"
buffer holding a decoded copy of the message. Inline content-types are
handled according to `rmail-mime-media-type-handlers-alist'.
By default, this displays text and multipart messages, and offers to
download attachments as specified by `rmail-mime-attachment-dirs-alist'.
The arguments ARG and STATE have no effect in this case.
\(fn &optional ARG STATE)" t nil)
;;;***
;;;### (autoloads nil "rmailmsc" "rmailmsc.el" "c3f0d33739768fc12acc4258ae0da72e")
;;; Generated autoloads from rmailmsc.el
(autoload 'set-rmail-inbox-list "rmailmsc" "\
Set the inbox list of the current RMAIL file to FILE-NAME.
You can specify one file name, or several names separated by commas.
If FILE-NAME is empty, remove any existing inbox list.
This applies only to the current session.
\(fn FILE-NAME)" t nil)
;;;***
;;;### (autoloads nil "rmailsort" "rmailsort.el" "8f551773021df4fa1a14ec2517e6a4f1")
;;; Generated autoloads from rmailsort.el
(autoload 'rmail-sort-by-date "rmailsort" "\
Sort messages of current Rmail buffer by \"Date\" header.
If prefix argument REVERSE is non-nil, sorts in reverse order.
\(fn REVERSE)" t nil)
(autoload 'rmail-sort-by-subject "rmailsort" "\
Sort messages of current Rmail buffer by \"Subject\" header.
Ignores any \"Re: \" prefix. If prefix argument REVERSE is
non-nil, sorts in reverse order.
\(fn REVERSE)" t nil)
(autoload 'rmail-sort-by-author "rmailsort" "\
Sort messages of current Rmail buffer by author.
This uses either the \"From\" or \"Sender\" header, downcased.
If prefix argument REVERSE is non-nil, sorts in reverse order.
\(fn REVERSE)" t nil)
(autoload 'rmail-sort-by-recipient "rmailsort" "\
Sort messages of current Rmail buffer by recipient.
This uses either the \"To\" or \"Apparently-To\" header, downcased.
If prefix argument REVERSE is non-nil, sorts in reverse order.
\(fn REVERSE)" t nil)
(autoload 'rmail-sort-by-correspondent "rmailsort" "\
Sort messages of current Rmail buffer by other correspondent.
This uses either the \"From\", \"Sender\", \"To\", or
\"Apparently-To\" header, downcased. Uses the first header not
excluded by `mail-dont-reply-to-names'. If prefix argument
REVERSE is non-nil, sorts in reverse order.
\(fn REVERSE)" t nil)
(autoload 'rmail-sort-by-lines "rmailsort" "\
Sort messages of current Rmail buffer by the number of lines.
If prefix argument REVERSE is non-nil, sorts in reverse order.
\(fn REVERSE)" t nil)
(autoload 'rmail-sort-by-labels "rmailsort" "\
Sort messages of current Rmail buffer by labels.
LABELS is a comma-separated list of labels. The order of these
labels specifies the order of messages: messages with the first
label come first, messages with the second label come second, and
so on. Messages that have none of these labels come last.
If prefix argument REVERSE is non-nil, sorts in reverse order.
\(fn REVERSE LABELS)" t nil)
;;;***
;;;### (autoloads nil "rmailsum" "rmailsum.el" "4bc0d1a65aede332348200e1937c84d4")
;;; Generated autoloads from rmailsum.el
(autoload 'rmail-summary "rmailsum" "\
Display a summary of all messages, one line per message.
\(fn)" t nil)
(autoload 'rmail-summary-by-labels "rmailsum" "\
Display a summary of all messages with one or more LABELS.
LABELS should be a string containing the desired labels, separated by commas.
\(fn LABELS)" t nil)
(autoload 'rmail-summary-by-recipients "rmailsum" "\
Display a summary of all messages with the given RECIPIENTS.
Normally checks the To, From and Cc fields of headers;
but if PRIMARY-ONLY is non-nil (prefix arg given),
only look in the To and From fields.
RECIPIENTS is a regular expression.
\(fn RECIPIENTS &optional PRIMARY-ONLY)" t nil)
(autoload 'rmail-summary-by-regexp "rmailsum" "\
Display a summary of all messages according to regexp REGEXP.
If the regular expression is found in the header of the message
\(including in the date and other lines, as well as the subject line),
Emacs will list the message in the summary.
\(fn REGEXP)" t nil)
(autoload 'rmail-summary-by-topic "rmailsum" "\
Display a summary of all messages with the given SUBJECT.
Normally checks just the Subject field of headers; but with prefix
argument WHOLE-MESSAGE is non-nil, looks in the whole message.
SUBJECT is a regular expression.
\(fn SUBJECT &optional WHOLE-MESSAGE)" t nil)
(autoload 'rmail-summary-by-senders "rmailsum" "\
Display a summary of all messages whose \"From\" field matches SENDERS.
SENDERS is a regular expression.
\(fn SENDERS)" t nil)
;;;***
;;;### (autoloads nil "undigest" "undigest.el" "c0ddfad4fe34ef9c1e790c2cc72b571d")
;;; Generated autoloads from undigest.el
(autoload 'undigestify-rmail-message "undigest" "\
Break up a digest message into its constituent messages.
Leaves original message, deleted, before the undigestified messages.
\(fn)" t nil)
(autoload 'unforward-rmail-message "undigest" "\
Extract a forwarded message from the containing message.
This puts the forwarded message into a separate rmail message following
the containing message. This command is only useful when messages are
forwarded with `rmail-enable-mime-composing' set to nil.
\(fn)" t nil)
;;;***
;;; End of automatically extracted autoloads.
(provide 'rmail)
;;; rmail.el ends here