comparison lisp/gnus/nnmail.el @ 110410:f2e111723c3a

Merge changes made in Gnus trunk. Reimplement nnimap, and do tweaks to the rest of the code to support that. * gnus-int.el (gnus-finish-retrieve-group-infos) (gnus-retrieve-group-data-early): New functions. * gnus-range.el (gnus-range-nconcat): New function. * gnus-start.el (gnus-get-unread-articles): Support early retrieval of data. (gnus-read-active-for-groups): Support finishing the early retrieval of data. * gnus-sum.el (gnus-summary-move-article): Pass the move-to group name if the move is internal, so that nnimap can do fast internal moves. * gnus.el (gnus-article-special-mark-lists): Add uid/active tuples, for nnimap usage. * nnimap.el: Rewritten. * nnmail.el (nnmail-inhibit-default-split-group): New internal variable to allow the mail splitting to not return a default group. This is useful for nnimap, which will leave unmatched mail in the inbox. * utf7.el (utf7-encode): Autoload. Implement shell connection. * nnimap.el (nnimap-open-shell-stream): New function. (nnimap-open-connection): Use it. Get the number of lines by using BODYSTRUCTURE. (nnimap-transform-headers): Get the number of lines in each message. (nnimap-retrieve-headers): Query for BODYSTRUCTURE so that we get the number of lines. Not all servers return UIDNEXT. Work past this problem. Remove junk from end of file. Fix typo in "bogus" section. Make capabilties be case-insensitive. Require cl when compiling. Don't bug out if the LIST command doesn't have any parameters. 2010-09-17 Knut Anders Hatlen <kahatlen@gmail.com> (tiny change) * nnimap.el (nnimap-get-groups): Don't bug out if the LIST command doesn't have any parameters. (mm-text-html-renderer): Document gnus-article-html. 2010-09-17 Julien Danjou <julien@danjou.info> (tiny fix) * mm-decode.el (mm-text-html-renderer): Document gnus-article-html. * dgnushack.el: Define netrc-credentials. If the user doesn't have a /etc/services, supply some sensible port defaults. Have `unseen-or-unread' select an unread unseen article first. (nntp-open-server): Return whether the open was successful or not. Throughout all files, replace (save-excursion (set-buffer ...)) with (with-current-buffer ... ). Save result so that it doesn't say "failed" all the time. Add ~/.authinfo to the default, since that's probably most useful for users. Don't use the "finish" method when we're reading from the agent. Add some more nnimap-relevant agent stuff to nnagent.el. * nnimap.el (nnimap-with-process-buffer): Removed. Revert one line that was changed by mistake in the last checkin. (nnimap-open-connection): Don't error out when we can't make a connection nnimap-related changes to avoid bugging out if we can't contact a server. * gnus-start.el (gnus-get-unread-articles): Don't try to scan groups from methods that are denied. * nnimap.el (nnimap-possibly-change-group): Return nil if we can't log in. (nnimap-finish-retrieve-group-infos): Make sure we're not waiting for nothing. * gnus-sum.el (gnus-select-newsgroup): Indent.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 18 Sep 2010 10:02:19 +0000
parents 821c596efa5f
children b7b7e970d807
comparison
equal deleted inserted replaced
110409:42d133e002e5 110410:f2e111723c3a
612 (defvar nnmail-prepare-save-mail-hook nil 612 (defvar nnmail-prepare-save-mail-hook nil
613 "Hook called before saving mail.") 613 "Hook called before saving mail.")
614 614
615 (defvar nnmail-split-tracing nil) 615 (defvar nnmail-split-tracing nil)
616 (defvar nnmail-split-trace nil) 616 (defvar nnmail-split-trace nil)
617 (defvar nnmail-inhibit-default-split-group nil)
617 618
618 619
619 620
620 (defun nnmail-request-post (&optional server) 621 (defun nnmail-request-post (&optional server)
621 (mail-send-and-exit nil)) 622 (mail-send-and-exit nil))
672 673
673 (defun nnmail-get-active () 674 (defun nnmail-get-active ()
674 "Returns an assoc of group names and active ranges. 675 "Returns an assoc of group names and active ranges.
675 nn*-request-list should have been called before calling this function." 676 nn*-request-list should have been called before calling this function."
676 ;; Go through all groups from the active list. 677 ;; Go through all groups from the active list.
677 (save-excursion 678 (with-current-buffer nntp-server-buffer
678 (set-buffer nntp-server-buffer)
679 (nnmail-parse-active))) 679 (nnmail-parse-active)))
680 680
681 (defun nnmail-parse-active () 681 (defun nnmail-parse-active ()
682 "Parse the active file in the current buffer and return an alist." 682 "Parse the active file in the current buffer and return an alist."
683 (goto-char (point-min)) 683 (goto-char (point-min))
1056 "Non-nil means group names are not encoded.") 1056 "Non-nil means group names are not encoded.")
1057 1057
1058 (defun nnmail-split-incoming (incoming func &optional exit-func 1058 (defun nnmail-split-incoming (incoming func &optional exit-func
1059 group artnum-func) 1059 group artnum-func)
1060 "Go through the entire INCOMING file and pick out each individual mail. 1060 "Go through the entire INCOMING file and pick out each individual mail.
1061 FUNC will be called with the buffer narrowed to each mail." 1061 FUNC will be called with the buffer narrowed to each mail.
1062 INCOMING can also be a buffer object. In that case, the mail
1063 will be copied over from that buffer."
1062 (let ( ;; If this is a group-specific split, we bind the split 1064 (let ( ;; If this is a group-specific split, we bind the split
1063 ;; methods to just this group. 1065 ;; methods to just this group.
1064 (nnmail-split-methods (if (and group 1066 (nnmail-split-methods (if (and group
1065 (not nnmail-resplit-incoming)) 1067 (not nnmail-resplit-incoming))
1066 (list (list group "")) 1068 (list (list group ""))
1067 nnmail-split-methods)) 1069 nnmail-split-methods))
1068 (nnmail-group-names-not-encoded-p t)) 1070 (nnmail-group-names-not-encoded-p t))
1069 (save-excursion 1071 ;; Insert the incoming file.
1070 ;; Insert the incoming file. 1072 (with-current-buffer (get-buffer-create nnmail-article-buffer)
1071 (set-buffer (get-buffer-create nnmail-article-buffer))
1072 (erase-buffer) 1073 (erase-buffer)
1073 (let ((coding-system-for-read nnmail-incoming-coding-system)) 1074 (if (bufferp incoming)
1074 (mm-insert-file-contents incoming)) 1075 (insert-buffer-substring incoming)
1076 (let ((coding-system-for-read nnmail-incoming-coding-system))
1077 (mm-insert-file-contents incoming)))
1075 (prog1 1078 (prog1
1076 (if (zerop (buffer-size)) 1079 (if (zerop (buffer-size))
1077 0 1080 0
1078 (goto-char (point-min)) 1081 (goto-char (point-min))
1079 (save-excursion (run-hooks 'nnmail-prepare-incoming-hook)) 1082 (save-excursion (run-hooks 'nnmail-prepare-incoming-hook))
1098 FUNC will be called with the group name to determine the article number." 1101 FUNC will be called with the group name to determine the article number."
1099 (let ((methods (or nnmail-split-methods '(("bogus" "")))) 1102 (let ((methods (or nnmail-split-methods '(("bogus" ""))))
1100 (obuf (current-buffer)) 1103 (obuf (current-buffer))
1101 group-art method grp) 1104 group-art method grp)
1102 (if (and (sequencep methods) 1105 (if (and (sequencep methods)
1103 (= (length methods) 1)) 1106 (= (length methods) 1)
1107 (not nnmail-inhibit-default-split-group))
1104 ;; If there is only just one group to put everything in, we 1108 ;; If there is only just one group to put everything in, we
1105 ;; just return a list with just this one method in. 1109 ;; just return a list with just this one method in.
1106 (setq group-art 1110 (setq group-art
1107 (list (cons (caar methods) (funcall func (caar methods))))) 1111 (list (cons (caar methods) (funcall func (caar methods)))))
1108 ;; We do actual comparison. 1112 ;; We do actual comparison.
1109 (save-excursion 1113 ;; Copy the article into the work buffer.
1110 ;; Copy the article into the work buffer. 1114 (with-current-buffer nntp-server-buffer
1111 (set-buffer nntp-server-buffer)
1112 (erase-buffer) 1115 (erase-buffer)
1113 (insert-buffer-substring obuf) 1116 (insert-buffer-substring obuf)
1114 ;; Narrow to headers. 1117 ;; Narrow to headers.
1115 (narrow-to-region 1118 (narrow-to-region
1116 (goto-char (point-min)) 1119 (goto-char (point-min))
1147 (condition-case error-info 1150 (condition-case error-info
1148 ;; `nnmail-split-methods' is a function, so we 1151 ;; `nnmail-split-methods' is a function, so we
1149 ;; just call this function here and use the 1152 ;; just call this function here and use the
1150 ;; result. 1153 ;; result.
1151 (or (funcall nnmail-split-methods) 1154 (or (funcall nnmail-split-methods)
1152 '("bogus")) 1155 (and (not nnmail-inhibit-default-split-group)
1156 '("bogus")))
1153 (error 1157 (error
1154 (nnheader-message 1158 (nnheader-message
1155 5 "Error in `nnmail-split-methods'; using `bogus' mail group: %S" error-info) 1159 5 "Error in `nnmail-split-methods'; using `bogus' mail group: %S" error-info)
1156 (sit-for 1) 1160 (sit-for 1)
1157 '("bogus"))))) 1161 '("bogus")))))
1192 (not (assoc grp group-art))) 1196 (not (assoc grp group-art)))
1193 (push (cons grp (funcall func grp)) 1197 (push (cons grp (funcall func grp))
1194 group-art)) 1198 group-art))
1195 ;; This is the final group, which is used as a 1199 ;; This is the final group, which is used as a
1196 ;; catch-all. 1200 ;; catch-all.
1197 (unless group-art 1201 (when (and (not group-art)
1202 (not nnmail-inhibit-default-split-group))
1198 (setq group-art 1203 (setq group-art
1199 (list (cons (car method) 1204 (list (cons (car method)
1200 (funcall func (car method)))))))) 1205 (funcall func (car method))))))))
1201 ;; Fall back on "bogus" if all else fails. 1206 ;; Fall back on "bogus" if all else fails.
1202 (unless group-art 1207 (when (and (not group-art)
1208 (not nnmail-inhibit-default-split-group))
1203 (setq group-art (list (cons "bogus" (funcall func "bogus")))))) 1209 (setq group-art (list (cons "bogus" (funcall func "bogus"))))))
1204 ;; Produce a trace if non-empty. 1210 ;; Produce a trace if non-empty.
1205 (when (and trace nnmail-split-trace) 1211 (when (and trace nnmail-split-trace)
1206 (let ((restore (current-buffer))) 1212 (let ((restore (current-buffer)))
1207 (nnheader-set-temp-buffer "*Split Trace*") 1213 (nnheader-set-temp-buffer "*Split Trace*")
1570 (defun nnmail-cache-open () 1576 (defun nnmail-cache-open ()
1571 (if (or (not nnmail-treat-duplicates) 1577 (if (or (not nnmail-treat-duplicates)
1572 (and nnmail-cache-buffer 1578 (and nnmail-cache-buffer
1573 (buffer-name nnmail-cache-buffer))) 1579 (buffer-name nnmail-cache-buffer)))
1574 () ; The buffer is open. 1580 () ; The buffer is open.
1575 (save-excursion 1581 (with-current-buffer
1576 (set-buffer
1577 (setq nnmail-cache-buffer 1582 (setq nnmail-cache-buffer
1578 (get-buffer-create " *nnmail message-id cache*"))) 1583 (get-buffer-create " *nnmail message-id cache*"))
1579 (gnus-add-buffer) 1584 (gnus-add-buffer)
1580 (when (file-exists-p nnmail-message-id-cache-file) 1585 (when (file-exists-p nnmail-message-id-cache-file)
1581 (nnheader-insert-file-contents nnmail-message-id-cache-file)) 1586 (nnheader-insert-file-contents nnmail-message-id-cache-file))
1582 (set-buffer-modified-p nil) 1587 (set-buffer-modified-p nil)
1583 (current-buffer)))) 1588 (current-buffer))))
1585 (defun nnmail-cache-close () 1590 (defun nnmail-cache-close ()
1586 (when (and nnmail-cache-buffer 1591 (when (and nnmail-cache-buffer
1587 nnmail-treat-duplicates 1592 nnmail-treat-duplicates
1588 (buffer-name nnmail-cache-buffer) 1593 (buffer-name nnmail-cache-buffer)
1589 (buffer-modified-p nnmail-cache-buffer)) 1594 (buffer-modified-p nnmail-cache-buffer))
1590 (save-excursion 1595 (with-current-buffer nnmail-cache-buffer
1591 (set-buffer nnmail-cache-buffer)
1592 ;; Weed out the excess number of Message-IDs. 1596 ;; Weed out the excess number of Message-IDs.
1593 (goto-char (point-max)) 1597 (goto-char (point-max))
1594 (when (search-backward "\n" nil t nnmail-message-id-cache-length) 1598 (when (search-backward "\n" nil t nnmail-message-id-cache-length)
1595 (progn 1599 (progn
1596 (beginning-of-line) 1600 (beginning-of-line)
1621 ;; has been called from have been checked and the group is available. 1625 ;; has been called from have been checked and the group is available.
1622 ;; The only ambiguous case is nnmail-check-duplication which will only 1626 ;; The only ambiguous case is nnmail-check-duplication which will only
1623 ;; pass the first (of possibly >1) group which matches. -Josh 1627 ;; pass the first (of possibly >1) group which matches. -Josh
1624 (unless (gnus-buffer-live-p nnmail-cache-buffer) 1628 (unless (gnus-buffer-live-p nnmail-cache-buffer)
1625 (nnmail-cache-open)) 1629 (nnmail-cache-open))
1626 (save-excursion 1630 (with-current-buffer nnmail-cache-buffer
1627 (set-buffer nnmail-cache-buffer)
1628 (goto-char (point-max)) 1631 (goto-char (point-max))
1629 (if (and grp (not (string= "" grp)) 1632 (if (and grp (not (string= "" grp))
1630 (gnus-methods-equal-p gnus-command-method 1633 (gnus-methods-equal-p gnus-command-method
1631 (nnmail-cache-primary-mail-backend))) 1634 (nnmail-cache-primary-mail-backend)))
1632 (let ((regexp (if (consp nnmail-cache-ignore-groups) 1635 (let ((regexp (if (consp nnmail-cache-ignore-groups)
1655 1658
1656 ;; Fetch the group name corresponding to the message id stored in the 1659 ;; Fetch the group name corresponding to the message id stored in the
1657 ;; cache. 1660 ;; cache.
1658 (defun nnmail-cache-fetch-group (id) 1661 (defun nnmail-cache-fetch-group (id)
1659 (when (and nnmail-treat-duplicates nnmail-cache-buffer) 1662 (when (and nnmail-treat-duplicates nnmail-cache-buffer)
1660 (save-excursion 1663 (with-current-buffer nnmail-cache-buffer
1661 (set-buffer nnmail-cache-buffer)
1662 (goto-char (point-max)) 1664 (goto-char (point-max))
1663 (when (search-backward id nil t) 1665 (when (search-backward id nil t)
1664 (beginning-of-line) 1666 (beginning-of-line)
1665 (skip-chars-forward "^\n\r\t") 1667 (skip-chars-forward "^\n\r\t")
1666 (unless (looking-at "[\r\n]") 1668 (unless (looking-at "[\r\n]")
1700 (setq res nil))) 1702 (setq res nil)))
1701 res))) 1703 res)))
1702 1704
1703 (defun nnmail-cache-id-exists-p (id) 1705 (defun nnmail-cache-id-exists-p (id)
1704 (when nnmail-treat-duplicates 1706 (when nnmail-treat-duplicates
1705 (save-excursion 1707 (with-current-buffer nnmail-cache-buffer
1706 (set-buffer nnmail-cache-buffer)
1707 (goto-char (point-max)) 1708 (goto-char (point-max))
1708 (search-backward id nil t)))) 1709 (search-backward id nil t))))
1709 1710
1710 (defun nnmail-fetch-field (header) 1711 (defun nnmail-fetch-field (header)
1711 (save-excursion 1712 (save-excursion