diff options
Diffstat (limited to 'lisp/mail')
-rw-r--r-- | lisp/mail/emacsbug.el | 121 | ||||
-rw-r--r-- | lisp/mail/feedmail.el | 23 | ||||
-rw-r--r-- | lisp/mail/mailabbrev.el | 11 | ||||
-rw-r--r-- | lisp/mail/rmail.el | 121 | ||||
-rw-r--r-- | lisp/mail/rmailedit.el | 24 | ||||
-rw-r--r-- | lisp/mail/rmailmm.el | 17 | ||||
-rw-r--r-- | lisp/mail/rmailsum.el | 1 | ||||
-rw-r--r-- | lisp/mail/sendmail.el | 3 | ||||
-rw-r--r-- | lisp/mail/smtpmail.el | 27 | ||||
-rw-r--r-- | lisp/mail/unrmail.el | 40 |
10 files changed, 190 insertions, 198 deletions
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el index 8ed645b15a2..c1bc7e2e1ab 100644 --- a/lisp/mail/emacsbug.el +++ b/lisp/mail/emacsbug.el @@ -60,10 +60,6 @@ ;; User options end here. -(defvar report-emacs-bug-tracker-url "http://debbugs.gnu.org/cgi/" - "Base URL of the GNU bugtracker. -Used for querying duplicates and linking to existing bugs.") - (defvar report-emacs-bug-orig-text nil "The automatically-created initial text of the bug report.") @@ -160,11 +156,6 @@ Prompts for bug subject. Leaves you in a mail buffer." (when (string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version) (setq topic (concat (match-string 1 emacs-version) "; " topic)))) (let ((from-buffer (current-buffer)) - ;; Put these properties on semantically-void text. - ;; report-emacs-bug-hook deletes these regions before sending. - (prompt-properties '(field emacsbug-prompt - intangible but-helpful - rear-nonsticky t)) (can-insert-mail (or (report-emacs-bug-can-use-xdg-email) (report-emacs-bug-can-use-osx-open))) user-point message-end-point) @@ -194,7 +185,7 @@ Prompts for bug subject. Leaves you in a mail buffer." (insert (format "The report will be sent to %s.\n\n" report-emacs-bug-address)) (insert "This bug report will be sent to the ") - (insert-button + (insert-text-button "Bug-GNU-Emacs" 'face 'link 'help-echo (concat "mouse-2, RET: Follow this link") @@ -202,7 +193,7 @@ Prompts for bug subject. Leaves you in a mail buffer." (browse-url "http://lists.gnu.org/archive/html/bug-gnu-emacs/")) 'follow-link t) (insert " mailing list\nand the GNU bug tracker at ") - (insert-button + (insert-text-button "debbugs.gnu.org" 'face 'link 'help-echo (concat "mouse-2, RET: Follow this link") @@ -220,11 +211,10 @@ usually do not have translators for other languages.\n\n"))) (insert "Please describe exactly what actions triggered the bug, and\n" "the precise symptoms of the bug. If you can, give a recipe\n" "starting from `emacs -Q':\n\n") - (add-text-properties (save-excursion - (rfc822-goto-eoh) - (line-beginning-position 2)) - (point) - prompt-properties) + (let ((txt (delete-and-extract-region + (save-excursion (rfc822-goto-eoh) (line-beginning-position 2)) + (point)))) + (insert (propertize "\n" 'display txt))) (setq user-point (point)) (insert "\n\n") @@ -236,7 +226,8 @@ usually do not have translators for other languages.\n\n"))) (if (file-readable-p debug-file) (insert "For information about debugging Emacs, please read the file\n" debug-file ".\n"))) - (add-text-properties (1+ user-point) (point) prompt-properties) + (let ((txt (delete-and-extract-region (1+ user-point) (point)))) + (insert (propertize "\n" 'display txt))) (insert "\n\nIn " (emacs-version) "\n") (if (stringp emacs-bzr-version) @@ -434,100 +425,8 @@ and send the mail again%s." from)) (not (yes-or-no-p (format "Is `%s' really your email address? " from))) - (error "Please edit the From address and try again")))) - ;; Delete the uninteresting text that was just to help fill out the report. - (rfc822-goto-eoh) - (forward-line 1) - (let ((pos (1- (point)))) - (while (setq pos (text-property-any pos (point-max) - 'field 'emacsbug-prompt)) - (delete-region pos (field-end (1+ pos))))))) - - -;; Querying the bug database - -(defvar report-emacs-bug-bug-alist nil) -(make-variable-buffer-local 'report-emacs-bug-bug-alist) -(defvar report-emacs-bug-choice-widget nil) -(make-variable-buffer-local 'report-emacs-bug-choice-widget) - -(defun report-emacs-bug-create-existing-bugs-buffer (bugs keywords) - (switch-to-buffer (get-buffer-create "*Existing Emacs Bugs*")) - (setq buffer-read-only t) - (let ((inhibit-read-only t)) - (erase-buffer) - (setq report-emacs-bug-bug-alist bugs) - (widget-insert (propertize (concat "Already known bugs (" - keywords "):\n\n") - 'face 'bold)) - (if bugs - (setq report-emacs-bug-choice-widget - (apply 'widget-create 'radio-button-choice - :value (caar bugs) - (let (items) - (dolist (bug bugs) - (push (list - 'url-link - :format (concat "Bug#" (number-to-string (nth 2 bug)) - ": " (cadr bug) "\n %[%v%]\n") - ;; FIXME: Why is only the link of the - ;; active item clickable? - (car bug)) - items)) - (nreverse items)))) - (widget-insert "No bugs matching your keywords found.\n")) - (widget-insert "\n") - (widget-create 'push-button - :notify (lambda (&rest ignore) - ;; TODO: Do something! - (message "Reporting new bug!")) - "Report new bug") - (when bugs - (widget-insert " ") - (widget-create 'push-button - :notify (lambda (&rest ignore) - (let ((val (widget-value report-emacs-bug-choice-widget))) - ;; TODO: Do something! - (message "Appending to bug %s!" - (nth 2 (assoc val report-emacs-bug-bug-alist))))) - "Append to chosen bug")) - (widget-insert " ") - (widget-create 'push-button - :notify (lambda (&rest ignore) - (kill-buffer)) - "Quit reporting bug") - (widget-insert "\n")) - (use-local-map widget-keymap) - (widget-setup) - (goto-char (point-min))) - -(defun report-emacs-bug-parse-query-results (status keywords) - (goto-char (point-min)) - (let (buglist) - (while (re-search-forward "<a href=\"bugreport\\.cgi\\?bug=\\([[:digit:]]+\\)\">\\([^<]+\\)</a>" nil t) - (let ((number (match-string 1)) - (subject (match-string 2))) - (when (not (string-match "^#" subject)) - (push (list - ;; first the bug URL - (concat report-emacs-bug-tracker-url - "bugreport.cgi?bug=" number) - ;; then the subject and number - subject (string-to-number number)) - buglist)))) - (report-emacs-bug-create-existing-bugs-buffer (nreverse buglist) keywords))) - -(defun report-emacs-bug-query-existing-bugs (keywords) - "Query for KEYWORDS at `report-emacs-bug-tracker-url', and return the result. -The result is an alist with items of the form (URL SUBJECT NO)." - (interactive "sBug keywords (comma separated): ") - (url-retrieve (concat report-emacs-bug-tracker-url - "pkgreport.cgi?include=subject%3A" - (replace-regexp-in-string "[[:space:]]+" "+" keywords) - ";package=emacs") - 'report-emacs-bug-parse-query-results (list keywords))) -(make-obsolete 'report-emacs-bug-query-existing-bugs - "use the `debbugs' package from GNU ELPA instead." "24.3") + (error "Please edit the From address and try again")))))) + (provide 'emacsbug) diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el index 4305094611a..0502e7f9487 100644 --- a/lisp/mail/feedmail.el +++ b/lisp/mail/feedmail.el @@ -590,7 +590,7 @@ header is fiddled after the From: header is fiddled." (defcustom feedmail-force-binary-write t "If non-nil, force writing file as binary (this applies to queues and Fcc:). On systems where there is a difference between binary and text files, -feedmail will temporarily manipulate the value of `buffer-file-type' +feedmail will temporarily manipulate the value of `coding-system-for-write' to make the writing as binary. If nil, writing will be in text mode. On systems where there is no distinction or where it is controlled by other variables or other means, this option has no effect." @@ -2016,7 +2016,6 @@ backup file names and the like)." (setq buffer-offer-save nil) (buffer-disable-undo blobby-buffer) (insert-file-contents-literally maybe-file) - (setq buffer-file-type t) ; binary (goto-char (point-min)) ;; if at least two line-endings with CRLF, translate the file (if (looking-at ".*\r\n.*\r\n") @@ -2334,7 +2333,10 @@ mapped to mostly alphanumerics for safety." (setq filename buffer-file-name) (setq filename (feedmail-create-queue-filename queue-directory))) ;; make binary file on DOS/Windows 95/Windows NT, etc - (let ((buffer-file-type feedmail-force-binary-write)) + (let ((coding-system-for-write + (if feedmail-force-binary-write + 'no-conversion + coding-system-for-write))) (write-file filename)) ;; convenient for moving from draft to q, for example (if (and previous-buffer-file-name (or (not is-fqm) (not is-in-this-dir)) @@ -2571,26 +2573,27 @@ mapped to mostly alphanumerics for safety." ;; Re-insert and handle any Fcc fields (and, optionally, ;; any Bcc). (when fcc - (let ((old (default-value 'buffer-file-type))) + (let ((coding-system-for-write + (if (and (memq system-type '(ms-dos windows-nt)) + feedmail-force-binary-write) + 'no-conversion + coding-system-for-write))) (unwind-protect (progn - (setq-default buffer-file-type - feedmail-force-binary-write) (insert fcc) (unless feedmail-nuke-bcc-in-fcc (if bcc-holder (insert bcc-holder)) (if resent-bcc-holder (insert resent-bcc-holder))) - + (run-hooks 'feedmail-before-fcc-hook) - + (when feedmail-nuke-body-in-fcc (goto-char eoh-marker) (if (natnump feedmail-nuke-body-in-fcc) (forward-line feedmail-nuke-body-in-fcc)) (delete-region (point) (point-max))) - (mail-do-fcc eoh-marker)) - (setq-default buffer-file-type old))))) + (mail-do-fcc eoh-marker)))))) ;; User bailed out of one-last-look. (if feedmail-queue-runner-is-active (throw 'skip-me-q 'skip-me-q) diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el index 271875e340c..981be8b6a98 100644 --- a/lisp/mail/mailabbrev.el +++ b/lisp/mail/mailabbrev.el @@ -182,7 +182,8 @@ no aliases, which is represented by this being a table with no entries.)") (nth 5 (file-attributes mail-personal-alias-file))) (build-mail-abbrevs))) (mail-abbrevs-sync-aliases) - (add-hook 'abbrev-expand-functions 'mail-abbrev-expand-wrapper nil t) + (add-function :around (local 'abbrev-expand-function) + #'mail-abbrev-expand-wrapper) (abbrev-mode 1)) (defun mail-abbrevs-enable () @@ -472,10 +473,12 @@ of a mail alias. The value is set up, buffer-local, when first needed.") (defun mail-abbrev-expand-wrapper (expand) (if (and mail-abbrevs (not (eq mail-abbrevs t))) - (if (mail-abbrev-in-expansion-header-p) + (if (or (mail-abbrev-in-expansion-header-p) + ;; Necessary for `message-read-from-minibuffer' to work. + (window-minibuffer-p)) - ;; We are in a To: (or CC:, or whatever) header, and - ;; should use word-abbrevs to expand mail aliases. + ;; We are in a To: (or CC:, or whatever) header or a minibuffer, + ;; and should use word-abbrevs to expand mail aliases. (let ((local-abbrev-table mail-abbrevs)) ;; Before anything else, resolve aliases if they need it. diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index da19b367f1f..02703026e84 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -100,6 +100,10 @@ its character representation and its display representation.") "The current header display style choice, one of 'normal (selected headers) or 'full (all headers).") +(defvar rmail-mime-decoded nil + "Non-nil if message has been processed by `rmail-show-mime-function'.") +(put 'rmail-mime-decoded 'permanent-local t) ; for rmail-edit + (defgroup rmail nil "Mail reader for Emacs." :group 'mail) @@ -1081,6 +1085,7 @@ The buffer is expected to be narrowed to just the header of the message." (define-key map "<" 'rmail-first-message) (define-key map ">" 'rmail-last-message) (define-key map " " 'scroll-up-command) + (define-key map [?\S-\ ] 'scroll-down-command) (define-key map "\177" 'scroll-down-command) (define-key map "?" 'describe-mode) (define-key map "\C-c\C-s\C-d" 'rmail-sort-by-date) @@ -1503,6 +1508,8 @@ If so restore the actual mbox message collection." (setq file-precious-flag t) (make-local-variable 'desktop-save-buffer) (setq desktop-save-buffer t) + (make-local-variable 'save-buffer-coding-system) + (setq save-buffer-coding-system 'no-conversion) (setq next-error-move-function 'rmail-next-error-move)) ;; Handle M-x revert-buffer done in an rmail-mode buffer. @@ -2169,20 +2176,35 @@ If MSGNUM is nil, use the current message." (defun rmail-set-header-1 (name value) "Subroutine of `rmail-set-header'. -Narrow to header, set header NAME to VALUE, replacing existing if present. -VALUE nil means to remove NAME altogether." +Narrow to headers, set header NAME to VALUE, replacing existing if present. +VALUE nil means to remove NAME altogether. + +Only changes the first instance of NAME. If VALUE is multi-line, +continuation lines should already be indented. VALUE should not +end in a newline." (if (search-forward "\n\n" nil t) (progn (forward-char -1) (narrow-to-region (point-min) (point)) + ;; cf mail-fetch-field. (goto-char (point-min)) - (if (re-search-forward (concat "^" (regexp-quote name) ":") nil 'move) + (if (let ((case-fold-search t)) + (re-search-forward (concat "^" (regexp-quote name) "[ \t]*:") + nil 'move)) + (let ((start (point)) + end) + (while (and (zerop (forward-line 1)) + (looking-at "[ \t]"))) + ;; Back up over newline. + (forward-char -1) + (setq end (point)) + (goto-char start) (if value (progn - (delete-region (point) (line-end-position)) + (delete-region start end) (insert " " value)) - (delete-region (line-beginning-position) - (line-beginning-position 2))) + (delete-region (line-beginning-position) (1+ end)))) + ;; Not already present: insert at end of headers. (if value (insert name ": " value "\n")))) (rmail-error-bad-format))) @@ -2699,6 +2721,27 @@ N defaults to the current message." :group 'rmail :version "23.1") +;; FIXME? +;; rmail-show-mime-function does not unquote >From lines. Should it? +(defcustom rmail-mbox-format 'mboxrd + "The mbox format that your system uses. +There is no way to determine this, so you should set the appropriate value. +The formats quote lines containing \"From \" differently. +The choices are: + `mboxo' : lines that start with \"From \" quoted as \">From \" + `mboxrd': lines that start with \">*From \" quoted with another \">\" +The `mboxo' format is ambiguous, in that one cannot know whether +a line starting with \">From \" originally had a \">\" or not. + +It is not critical to set this to the correct value; it only affects +how Rmail displays lines starting with \">*From \" in non-MIME messages. + +See also `unrmail-mbox-format'." + :type '(choice (const mboxrd) + (const mboxro)) + :version "24.4" + :group 'rmail-files) + (defun rmail-show-message-1 (&optional msg) "Show message MSG (default: current message) using `rmail-view-buffer'. Return text to display in the minibuffer if MSG is out of @@ -2747,6 +2790,7 @@ The current mail message becomes the message displayed." (re-search-forward "mime-version: 1.0" nil t)) (let ((rmail-buffer mbox-buf) (rmail-view-buffer view-buf)) + (set (make-local-variable 'rmail-mime-decoded) t) (funcall rmail-show-mime-function)) (setq body-start (search-forward "\n\n" nil t)) (narrow-to-region beg (point)) @@ -2791,11 +2835,15 @@ The current mail message becomes the message displayed." ;; Prepare the separator (blank line) before the body. (goto-char (point-min)) (insert "\n") - ;; Unquote quoted From lines - (while (re-search-forward "^>+From " nil t) - (beginning-of-line) - (delete-char 1) - (forward-line)) + ;; Unquote quoted From lines. + (let ((fromline (if (eq 'mboxrd rmail-mbox-format) + "^>+From " + "^>From ")) + case-fold-search) + (while (re-search-forward fromline nil t) + (beginning-of-line) + (delete-char 1) + (forward-line))) (goto-char (point-min))) ;; Copy the headers to the front of the message view buffer. (rmail-copy-headers beg end) @@ -3869,6 +3917,7 @@ see the documentation of `rmail-resend'." (msgnum rmail-current-message) (subject (concat "[" (let ((from (or (mail-fetch-field "From") + ;; FIXME - huh? (mail-fetch-field ">From")))) (if from (concat (mail-strip-quoted-names from) ": ") @@ -4193,31 +4242,25 @@ This has an effect only if a summary buffer exists." ;; Put the summary buffer back on the screen, if user wants that. (defun rmail-maybe-display-summary () - (let ((selected (selected-window)) - (buffer (current-buffer)) - window) - ;; If requested, make sure the summary is displayed. - (and rmail-summary-buffer (buffer-name rmail-summary-buffer) - rmail-redisplay-summary - (if (get-buffer-window rmail-summary-buffer 0) - ;; It's already in some frame; show that one. - (let ((frame (window-frame - (get-buffer-window rmail-summary-buffer 0)))) - (make-frame-visible frame) - (raise-frame frame)) - (display-buffer rmail-summary-buffer))) - ;; If requested, set the height of the summary window. - (and rmail-summary-buffer (buffer-name rmail-summary-buffer) - rmail-summary-window-size - (setq window (get-buffer-window rmail-summary-buffer)) - ;; Don't try to change the size if just one window in frame. - (not (eq window (frame-root-window (window-frame window)))) - (unwind-protect - (progn - (select-window window) - (enlarge-window (- rmail-summary-window-size (window-height)))) - (select-window selected) - (set-buffer buffer))))) + (cond + ((or (not rmail-summary-buffer) + (not (buffer-name rmail-summary-buffer)))) + (rmail-redisplay-summary + ;; If `rmail-redisplay-summary' is non-nil, make sure the summary + ;; buffer is displayed. + (display-buffer + rmail-summary-buffer + `(nil + (reusable-frames . 0) + ,(when rmail-summary-window-size + `(window-height . ,rmail-summary-window-size))))) + (rmail-summary-window-size + ;; If `rmail-summary-window-size' is non-nil and the summary buffer + ;; is displayed, make sure it gets resized. + (let ((window (get-buffer-window rmail-summary-buffer 0))) + (when window + (window-resize-no-error + window (- rmail-summary-window-size (window-height window)))))))) ;;;; *** Rmail Local Fontification *** @@ -4552,7 +4595,7 @@ encoded string (and the same mask) will decode the string." ;;; Start of automatically extracted autoloads. ;;;### (autoloads (rmail-edit-current-message) "rmailedit" "rmailedit.el" -;;;;;; "1aec1d54f9767ee0fea557bbfb1d547b") +;;;;;; "0b056146d4775080a1847b8ce7527bc5") ;;; Generated autoloads from rmailedit.el (autoload 'rmail-edit-current-message "rmailedit" "\ @@ -4607,7 +4650,7 @@ With prefix argument N moves forward N messages with these labels. ;;;*** -;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "da37981a8295ba2411fdfb77488b1cc3") +;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "93951f748e43e1015da1b485088970ca") ;;; Generated autoloads from rmailmm.el (autoload 'rmail-mime "rmailmm" "\ @@ -4709,7 +4752,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order. ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic ;;;;;; rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels -;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "341825201e892b8fc875c1ae49ffd560") +;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "119ce8b431f01e7f54bb6fa99603b3d9") ;;; Generated autoloads from rmailsum.el (autoload 'rmail-summary "rmailsum" "\ diff --git a/lisp/mail/rmailedit.el b/lisp/mail/rmailedit.el index b880e21b8ca..68fc35e0e2a 100644 --- a/lisp/mail/rmailedit.el +++ b/lisp/mail/rmailedit.el @@ -167,10 +167,25 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. (if (or rmail-old-mime-state (not rmail-old-pruned)) (forward-line 1)) - (while (re-search-forward "^>*From " nil t) - (beginning-of-line) - (insert ">") - (forward-line)) + ;; When editing a non-MIME message, rmail-show-message-1 has unescaped + ;; ^>*From lines according to rmail-mbox-format. We are editing + ;; the message as it was displayed, and need to put the escapes when done. + ;; When editing a MIME message, we are editing the "raw" message. + ;; ^>*From lines have not been escaped, but we still need to ensure + ;; a "^From " line is escaped so as not to break later parsing (?). + ;; With ^>+From lines, we have no way of knowing whether the person + ;; doing the editing escaped them or not, so it seems best to leave + ;; them alone. (This all assumes you are using rmailmm rather than + ;; something else that behaves differently.) + (let ((fromline (if (or (eq 'mboxo rmail-mbox-format) + rmail-mime-decoded) + "^From " + "^>*From ")) + case-fold-search) + (while (re-search-forward fromline nil t) + (beginning-of-line) + (insert ">") + (forward-line))) ;; Make sure buffer ends with a blank line so as not to run this ;; message together with the following one. (goto-char (point-max)) @@ -201,6 +216,7 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. (setq buffer-undo-list t) (rmail-variables)) ;; If text has really changed, mark message as edited. + ;; FIXME we should do the comparison before escaping From lines. (unless (and (= (length old) (- (point-max) (point-min))) (string= old (buffer-substring (point-min) (point-max)))) (setq old nil) diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el index 71590f51dcb..350e3dacbcf 100644 --- a/lisp/mail/rmailmm.el +++ b/lisp/mail/rmailmm.el @@ -1365,14 +1365,15 @@ The arguments ARG and STATE have no effect in this case." (defun rmail-insert-mime-forwarded-message (forward-buffer) "Insert the message in FORWARD-BUFFER as a forwarded message. This is the usual value of `rmail-insert-mime-forwarded-message-function'." - (let ((message-buffer - (with-current-buffer forward-buffer - (if rmail-buffer-swapped - forward-buffer - rmail-view-buffer)))) - (save-restriction - (narrow-to-region (point) (point)) - (message-forward-make-body-mime message-buffer)))) + (let (contents-buffer start end) + (with-current-buffer forward-buffer + (setq contents-buffer + (if rmail-buffer-swapped + rmail-view-buffer + forward-buffer) + start (rmail-msgbeg rmail-current-message) + end (rmail-msgend rmail-current-message))) + (message-forward-make-body-mime contents-buffer start end))) (setq rmail-insert-mime-forwarded-message-function 'rmail-insert-mime-forwarded-message) diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el index 5b906719c39..13cd7c3f05e 100644 --- a/lisp/mail/rmailsum.el +++ b/lisp/mail/rmailsum.el @@ -118,6 +118,7 @@ Setting this option to nil might speed up the generation of summaries." (define-key map "<" 'rmail-summary-first-message) (define-key map ">" 'rmail-summary-last-message) (define-key map " " 'rmail-summary-scroll-msg-up) + (define-key map [?\S-\ ] 'rmail-summary-scroll-msg-down) (define-key map "\177" 'rmail-summary-scroll-msg-down) (define-key map "?" 'describe-mode) (define-key map "\C-c\C-n" 'rmail-summary-next-same-subject) diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index e86229a5cfb..e1dee3295f2 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -1493,6 +1493,9 @@ just append to the file, in Babyl format if necessary." (insert "\nMail-Followup-To: ")))) (defun mail-position-on-field (field &optional soft) + "Move to the start of the contents of header field FIELD. +If there is none, insert one, unless SOFT is non-nil. +If there are multiple FIELD fields, this goes to the first." (let (end (case-fold-search t)) (setq end (mail-header-end)) diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 534c5fcb523..5bfa29a0175 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -529,6 +529,18 @@ The list is in preference order.") password (plist-get auth-info :secret))) (when (functionp password) (setq password (funcall password))) + (let ((result (catch 'done + (smtpmail-try-auth-method process mech user password)))) + (if (stringp result) + (progn + (auth-source-forget+ :host host :port port) + (throw 'done result)) + (when save-function + (funcall save-function)) + result)))) + +(defun smtpmail-try-auth-method (process mech user password) + (let (ret) (cond ((or (not mech) (not user) @@ -554,16 +566,11 @@ The list is in preference order.") ;; are taken as a response to the server, and the ;; authentication fails. (encoded (base64-encode-string response t))) - (smtpmail-command-or-throw process encoded) - (when save-function - (funcall save-function))))) + (smtpmail-command-or-throw process encoded)))) ((eq mech 'login) (smtpmail-command-or-throw process "AUTH LOGIN") - (smtpmail-command-or-throw - process (base64-encode-string user t)) - (smtpmail-command-or-throw process (base64-encode-string password t)) - (when save-function - (funcall save-function))) + (smtpmail-command-or-throw process (base64-encode-string user t)) + (smtpmail-command-or-throw process (base64-encode-string password t))) ((eq mech 'plain) ;; We used to send an empty initial request, and wait for an ;; empty response, and then send the password, but this @@ -574,9 +581,7 @@ The list is in preference order.") process (concat "AUTH PLAIN " (base64-encode-string (concat "\0" user "\0" password) t)) - 235) - (when save-function - (funcall save-function))) + 235)) (t (error "Mechanism %s not implemented" mech))))) diff --git a/lisp/mail/unrmail.el b/lisp/mail/unrmail.el index f6347d11051..698e9b0e0a0 100644 --- a/lisp/mail/unrmail.el +++ b/lisp/mail/unrmail.el @@ -1,4 +1,4 @@ -;;; unrmail.el --- convert Rmail Babyl files to mailbox files +;;; unrmail.el --- convert Rmail Babyl files to mbox files ;; Copyright (C) 1992, 2001-2013 Free Software Foundation, Inc. @@ -26,7 +26,7 @@ ;;;###autoload (defun batch-unrmail () - "Convert old-style Rmail Babyl files to system inbox format. + "Convert old-style Rmail Babyl files to mbox format. Specify the input Rmail Babyl file names as command line arguments. For each Rmail file, the corresponding output file name is made by adding `.mail' at the end. @@ -45,9 +45,26 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'." (declare-function mail-mbox-from "mail-utils" ()) (defvar rmime-magic-string) ; in rmime.el, if you have it +(defcustom unrmail-mbox-format 'mboxrd + "The mbox format that `unrmail' should produce. +These formats separate messages using lines that start with \"From \". +Therefore any lines in the message bodies that start with \"From \" +must be quoted. The `mboxo' format just prepends a \">\" to such lines. +This is not reversible, because given a line starting with \">From \" in +an mboxo file, it is not possible to know whether the original had a \">\" +or not. The `mxbord' format avoids this by also quoting \">From \" as +\">>From \", and so on. For this reason, mboxrd is recommended. + +See also `rmail-mbox-format'." + :type '(choice (const mboxrd) + (const mboxro)) + :version "24.4" + :group 'rmail-files) + ;;;###autoload (defun unrmail (file to-file) - "Convert old-style Rmail Babyl file FILE to system inbox format file TO-FILE." + "Convert old-style Rmail Babyl file FILE to mbox format file TO-FILE. +The variable `unrmail-mbox-format' controls which mbox format to use." (interactive "fUnrmail (babyl file): \nFUnrmail into (new mailbox file): ") (with-temp-buffer ;; Read in the old Rmail file with no decoding. @@ -223,14 +240,15 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'." (insert "X-RMAIL-ATTRIBUTES: " (apply 'string attrs) "\n") (when keywords (insert "X-RMAIL-KEYWORDS: " keywords "\n")) - (goto-char (point-min)) - ;; ``Quote'' "\nFrom " as "\n>From " - ;; (note that this isn't really quoting, as there is no requirement - ;; that "\n[>]+From " be quoted in the same transparent way.) - (let ((case-fold-search nil)) - (while (search-forward "\nFrom " nil t) - (forward-char -5) - (insert ?>))) + ;; Convert From to >From, etc. + (let ((case-fold-search nil) + (fromline (if (eq 'mboxrd unrmail-mbox-format) + "^>*From " + "^From "))) + (while (re-search-forward fromline nil t) + (beginning-of-line) + (insert ?>) + (forward-line 1))) (goto-char (point-max)) ;; Add terminator blank line to message. (insert "\n") |