comparison lisp/gnus/nndiary.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 8d09094063d0
children 93e093c035a0
comparison
equal deleted inserted replaced
110409:42d133e002e5 110410:f2e111723c3a
378 378
379 (nnoo-define-basics nndiary) 379 (nnoo-define-basics nndiary)
380 380
381 (deffoo nndiary-retrieve-headers (sequence &optional group server fetch-old) 381 (deffoo nndiary-retrieve-headers (sequence &optional group server fetch-old)
382 (when (nndiary-possibly-change-directory group server) 382 (when (nndiary-possibly-change-directory group server)
383 (save-excursion 383 (with-current-buffer nntp-server-buffer
384 (set-buffer nntp-server-buffer)
385 (erase-buffer) 384 (erase-buffer)
386 (let* ((file nil) 385 (let* ((file nil)
387 (number (length sequence)) 386 (number (length sequence))
388 (count 0) 387 (count 0)
389 (file-name-coding-system nnmail-pathname-coding-system) 388 (file-name-coding-system nnmail-pathname-coding-system)
613 (nndiary-deletable-article-p group article) 612 (nndiary-deletable-article-p group article)
614 (nndiary-request-article article group server) 613 (nndiary-request-article article group server)
615 (let (nndiary-current-directory 614 (let (nndiary-current-directory
616 nndiary-current-group 615 nndiary-current-group
617 nndiary-article-file-alist) 616 nndiary-article-file-alist)
618 (save-excursion 617 (with-current-buffer buf
619 (set-buffer buf)
620 (insert-buffer-substring nntp-server-buffer) 618 (insert-buffer-substring nntp-server-buffer)
621 (setq result (eval accept-form)) 619 (setq result (eval accept-form))
622 (kill-buffer (current-buffer)) 620 (kill-buffer (current-buffer))
623 result)) 621 result))
624 (progn 622 (progn
670 (deffoo nndiary-request-post (&optional server) 668 (deffoo nndiary-request-post (&optional server)
671 (nnmail-do-request-post 'nndiary-request-accept-article server)) 669 (nnmail-do-request-post 'nndiary-request-accept-article server))
672 670
673 (deffoo nndiary-request-replace-article (article group buffer) 671 (deffoo nndiary-request-replace-article (article group buffer)
674 (nndiary-possibly-change-directory group) 672 (nndiary-possibly-change-directory group)
675 (save-excursion 673 (with-current-buffer buffer
676 (set-buffer buffer)
677 (nndiary-possibly-create-directory group) 674 (nndiary-possibly-create-directory group)
678 (let ((chars (nnmail-insert-lines)) 675 (let ((chars (nnmail-insert-lines))
679 (art (concat (int-to-string article) "\t")) 676 (art (concat (int-to-string article) "\t"))
680 headers) 677 headers)
681 (when (ignore-errors 678 (when (ignore-errors
686 nndiary-current-directory)) 683 nndiary-current-directory))
687 nil (if (nnheader-be-verbose 5) nil 'nomesg)) 684 nil (if (nnheader-be-verbose 5) nil 'nomesg))
688 t) 685 t)
689 (setq headers (nndiary-parse-head chars article)) 686 (setq headers (nndiary-parse-head chars article))
690 ;; Replace the NOV line in the NOV file. 687 ;; Replace the NOV line in the NOV file.
691 (save-excursion 688 (with-current-buffer (nndiary-open-nov group)
692 (set-buffer (nndiary-open-nov group))
693 (goto-char (point-min)) 689 (goto-char (point-min))
694 (if (or (looking-at art) 690 (if (or (looking-at art)
695 (search-forward (concat "\n" art) nil t)) 691 (search-forward (concat "\n" art) nil t))
696 ;; Delete the old NOV line. 692 ;; Delete the old NOV line.
697 (delete-region (progn (beginning-of-line) (point)) 693 (delete-region (progn (beginning-of-line) (point))
840 (not (eq (cdr (nth 1 (assoc group nndiary-group-alist))) 836 (not (eq (cdr (nth 1 (assoc group nndiary-group-alist)))
841 article))))))) 837 article)))))))
842 838
843 ;; Find an article number in the current group given the Message-ID. 839 ;; Find an article number in the current group given the Message-ID.
844 (defun nndiary-find-group-number (id) 840 (defun nndiary-find-group-number (id)
845 (save-excursion 841 (with-current-buffer (get-buffer-create " *nndiary id*")
846 (set-buffer (get-buffer-create " *nndiary id*"))
847 (let ((alist nndiary-group-alist) 842 (let ((alist nndiary-group-alist)
848 number) 843 number)
849 ;; We want to look through all .overview files, but we want to 844 ;; We want to look through all .overview files, but we want to
850 ;; start with the one in the current directory. It seems most 845 ;; start with the one in the current directory. It seems most
851 ;; likely that the article we are looking for is in that group. 846 ;; likely that the article we are looking for is in that group.
886 (if (or gnus-nov-is-evil nndiary-nov-is-evil) 881 (if (or gnus-nov-is-evil nndiary-nov-is-evil)
887 nil 882 nil
888 (let ((nov (expand-file-name nndiary-nov-file-name 883 (let ((nov (expand-file-name nndiary-nov-file-name
889 nndiary-current-directory))) 884 nndiary-current-directory)))
890 (when (file-exists-p nov) 885 (when (file-exists-p nov)
891 (save-excursion 886 (with-current-buffer nntp-server-buffer
892 (set-buffer nntp-server-buffer)
893 (erase-buffer) 887 (erase-buffer)
894 (nnheader-insert-file-contents nov) 888 (nnheader-insert-file-contents nov)
895 (if (and fetch-old 889 (if (and fetch-old
896 (not (numberp fetch-old))) 890 (not (numberp fetch-old)))
897 t ; Don't remove anything. 891 t ; Don't remove anything.
987 (setcdr active (1+ (cdr active)))) 981 (setcdr active (1+ (cdr active))))
988 (cdr active))) 982 (cdr active)))
989 983
990 (defun nndiary-add-nov (group article headers) 984 (defun nndiary-add-nov (group article headers)
991 "Add a nov line for the GROUP base." 985 "Add a nov line for the GROUP base."
992 (save-excursion 986 (with-current-buffer (nndiary-open-nov group)
993 (set-buffer (nndiary-open-nov group))
994 (goto-char (point-max)) 987 (goto-char (point-max))
995 (mail-header-set-number headers article) 988 (mail-header-set-number headers article)
996 (nnheader-insert-nov headers))) 989 (nnheader-insert-nov headers)))
997 990
998 (defsubst nndiary-header-value () 991 (defsubst nndiary-header-value ()
1013 1006
1014 (defun nndiary-open-nov (group) 1007 (defun nndiary-open-nov (group)
1015 (or (cdr (assoc group nndiary-nov-buffer-alist)) 1008 (or (cdr (assoc group nndiary-nov-buffer-alist))
1016 (let ((buffer (get-buffer-create (format " *nndiary overview %s*" 1009 (let ((buffer (get-buffer-create (format " *nndiary overview %s*"
1017 group)))) 1010 group))))
1018 (save-excursion 1011 (with-current-buffer buffer
1019 (set-buffer buffer)
1020 (set (make-local-variable 'nndiary-nov-buffer-file-name) 1012 (set (make-local-variable 'nndiary-nov-buffer-file-name)
1021 (expand-file-name 1013 (expand-file-name
1022 nndiary-nov-file-name 1014 nndiary-nov-file-name
1023 (nnmail-group-pathname group nndiary-directory))) 1015 (nnmail-group-pathname group nndiary-directory)))
1024 (erase-buffer) 1016 (erase-buffer)
1101 (defun nndiary-generate-nov-file (dir files) 1093 (defun nndiary-generate-nov-file (dir files)
1102 (let* ((dir (file-name-as-directory dir)) 1094 (let* ((dir (file-name-as-directory dir))
1103 (nov (concat dir nndiary-nov-file-name)) 1095 (nov (concat dir nndiary-nov-file-name))
1104 (nov-buffer (get-buffer-create " *nov*")) 1096 (nov-buffer (get-buffer-create " *nov*"))
1105 chars file headers) 1097 chars file headers)
1106 (save-excursion 1098 ;; Init the nov buffer.
1107 ;; Init the nov buffer. 1099 (with-current-buffer nov-buffer
1108 (set-buffer nov-buffer)
1109 (buffer-disable-undo) 1100 (buffer-disable-undo)
1110 (erase-buffer) 1101 (erase-buffer)
1111 (set-buffer nntp-server-buffer) 1102 (set-buffer nntp-server-buffer)
1112 ;; Delete the old NOV file. 1103 ;; Delete the old NOV file.
1113 (when (file-exists-p nov) 1104 (when (file-exists-p nov)
1123 (setq chars (- (point-max) (point))) 1114 (setq chars (- (point-max) (point)))
1124 (max 1 (1- (point))))) 1115 (max 1 (1- (point)))))
1125 (unless (zerop (buffer-size)) 1116 (unless (zerop (buffer-size))
1126 (goto-char (point-min)) 1117 (goto-char (point-min))
1127 (setq headers (nndiary-parse-head chars (caar files))) 1118 (setq headers (nndiary-parse-head chars (caar files)))
1128 (save-excursion 1119 (with-current-buffer nov-buffer
1129 (set-buffer nov-buffer)
1130 (goto-char (point-max)) 1120 (goto-char (point-max))
1131 (nnheader-insert-nov headers))) 1121 (nnheader-insert-nov headers)))
1132 (widen)) 1122 (widen))
1133 (setq files (cdr files))) 1123 (setq files (cdr files)))
1134 (save-excursion 1124 (with-current-buffer nov-buffer
1135 (set-buffer nov-buffer)
1136 (nnmail-write-region 1 (point-max) nov nil 'nomesg) 1125 (nnmail-write-region 1 (point-max) nov nil 'nomesg)
1137 (kill-buffer (current-buffer)))))) 1126 (kill-buffer (current-buffer))))))
1138 1127
1139 (defun nndiary-nov-delete-article (group article) 1128 (defun nndiary-nov-delete-article (group article)
1140 (save-excursion 1129 (with-current-buffer (nndiary-open-nov group)
1141 (set-buffer (nndiary-open-nov group))
1142 (when (nnheader-find-nov-line article) 1130 (when (nnheader-find-nov-line article)
1143 (delete-region (point) (progn (forward-line 1) (point))) 1131 (delete-region (point) (progn (forward-line 1) (point)))
1144 (when (bobp) 1132 (when (bobp)
1145 (let ((active (cadr (assoc group nndiary-group-alist))) 1133 (let ((active (cadr (assoc group nndiary-group-alist)))
1146 num) 1134 num)