changeset 111070:25ddbcf2f2ea

Allow nnimap article editing (sort of). gnus-sum.el (gnus-summary-edit-article-done): Try to replace articles that have gotten new numbers. nnimap.el (nnimap-request-replace-article): New function.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 21 Oct 2010 01:23:34 +0000
parents a08c05a1c2cf
children 28e0e0ac22e4
files lisp/gnus/ChangeLog lisp/gnus/gnus-sum.el lisp/gnus/mm-decode.el lisp/gnus/nnimap.el
diffstat 4 files changed, 47 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Thu Oct 21 00:33:40 2010 +0000
+++ b/lisp/gnus/ChangeLog	Thu Oct 21 01:23:34 2010 +0000
@@ -1,3 +1,10 @@
+2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-sum.el (gnus-summary-edit-article-done): Try to replace articles
+	that have gotten new numbers.
+
+	* nnimap.el (nnimap-request-replace-article): New function.
+
 2010-10-21  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* nnrss.el (nnrss-wash-html-in-text-plain-parts): Remove.
--- a/lisp/gnus/gnus-sum.el	Thu Oct 21 00:33:40 2010 +0000
+++ b/lisp/gnus/gnus-sum.el	Thu Oct 21 01:23:34 2010 +0000
@@ -10257,7 +10257,7 @@
   "Make edits to the current article permanent."
   (interactive)
   (save-excursion
-   ;; The buffer restriction contains the entire article if it exists.
+    ;; The buffer restriction contains the entire article if it exists.
     (when (article-goto-body)
       (let ((lines (count-lines (point) (point-max)))
 	    (length (- (point-max) (point)))
@@ -10277,15 +10277,24 @@
 	  (delete-region (match-beginning 1) (match-end 1))
 	  (insert (number-to-string lines))))))
   ;; Replace the article.
-  (let ((buf (current-buffer)))
+  (let ((buf (current-buffer))
+	(article (cdr gnus-article-current)))
     (with-temp-buffer
       (insert-buffer-substring buf)
-
       (if (and (not read-only)
-	       (not (gnus-request-replace-article
-		     (cdr gnus-article-current) (car gnus-article-current)
-		     (current-buffer) t)))
+	       (not (setq replace-result
+			  (gnus-request-replace-article
+			   article (car gnus-article-current)
+			   (current-buffer) t))))
 	  (error "Couldn't replace article")
+	;; If we got a number back, then that's the new article number
+	;; for this article.  Otherwise, the article number didn't change.
+	(when (numberp replace-result)
+	  (with-current-buffer gnus-summary-buffer
+	    (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
+	    (gnus-summary-limit gnus-newsgroup-limit)
+	    (setq article replace-result)
+	    (gnus-summary-goto-subject article t)))
 	;; Update the summary buffer.
 	(if (and references
 		 (equal (message-tokenize-header references " ")
@@ -10299,38 +10308,29 @@
 			     (point-min) (point-max)))
 		      header)
 		  (with-temp-buffer
-		    (insert (format "211 %d Article retrieved.\n"
-				    (cdr gnus-article-current)))
+		    (insert (format "211 %d Article retrieved.\n" article))
 		    (insert head)
 		    (insert ".\n")
 		    (let ((nntp-server-buffer (current-buffer)))
-		      (setq header (car (gnus-get-newsgroup-headers
-					 nil t))))
+		      (setq header (car (gnus-get-newsgroup-headers nil t))))
 		    (with-current-buffer gnus-summary-buffer
-		      (gnus-data-set-header
-		       (gnus-data-find (cdr gnus-article-current))
-		       header)
-		      (gnus-summary-update-article-line
-		       (cdr gnus-article-current) header)
-		      (if (gnus-summary-goto-subject
-			   (cdr gnus-article-current) nil t)
-			  (gnus-summary-update-secondary-mark
-			   (cdr gnus-article-current))))))))
+		      (gnus-data-set-header (gnus-data-find article) header)
+		      (gnus-summary-update-article-line article header)
+		      (if (gnus-summary-goto-subject article nil t)
+			  (gnus-summary-update-secondary-mark article)))))))
 	  ;; Update threads.
 	  (set-buffer (or buffer gnus-summary-buffer))
-	  (gnus-summary-update-article (cdr gnus-article-current))
-	  (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
-	      (gnus-summary-update-secondary-mark
-	       (cdr gnus-article-current))))
+	  (gnus-summary-update-article article)
+	  (if (gnus-summary-goto-subject article nil t)
+	      (gnus-summary-update-secondary-mark article)))
 	;; Prettify the article buffer again.
 	(unless no-highlight
 	  (with-current-buffer gnus-article-buffer
-	    ;;;!!! Fix this -- article should be rehighlighted.
-	    ;;;(gnus-run-hooks 'gnus-article-display-hook)
+	    ;;!!! Fix this -- article should be rehighlighted.
+	    ;;(gnus-run-hooks 'gnus-article-display-hook)
 	    (set-buffer gnus-original-article-buffer)
 	    (gnus-request-article
-	     (cdr gnus-article-current)
-	     (car gnus-article-current) (current-buffer))))
+	     article (car gnus-article-current) (current-buffer))))
 	;; Prettify the summary buffer line.
 	(when (gnus-visual-p 'summary-highlight 'highlight)
 	  (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
--- a/lisp/gnus/mm-decode.el	Thu Oct 21 00:33:40 2010 +0000
+++ b/lisp/gnus/mm-decode.el	Thu Oct 21 01:23:34 2010 +0000
@@ -1690,7 +1690,7 @@
 	(shr-blocked-images (if (and (boundp 'gnus-summary-buffer)
 				     (buffer-name gnus-summary-buffer))
 				(with-current-buffer gnus-summary-buffer
-				  gnus-blocked-images)
+				  (gnus-blocked-images))
 			      shr-blocked-images))
 	(shr-content-function (lambda (id)
 				(let ((handle (mm-get-content-id id)))
--- a/lisp/gnus/nnimap.el	Thu Oct 21 00:33:40 2010 +0000
+++ b/lisp/gnus/nnimap.el	Thu Oct 21 01:23:34 2010 +0000
@@ -881,7 +881,7 @@
     (let ((message-id (message-field-value "message-id"))
 	  sequence message)
       (nnimap-add-cr)
-      (setq message (buffer-string))
+      (setq message (buffer-substring-no-properties (point-min) (point-max)))
       (with-current-buffer (nnimap-buffer)
 	(setq sequence (nnimap-send-command
 			"APPEND %S {%d}" (utf7-encode group t)
@@ -899,6 +899,17 @@
 	    (cons group
 		  (nnimap-find-article-by-message-id group message-id))))))))
 
+(deffoo nnimap-request-replace-article (article group buffer)
+  (let (group-art)
+    (when (and (nnimap-possibly-change-group group nil)
+	       ;; Put the article into the group.
+	       (with-current-buffer buffer
+		 (setq group-art
+		       (nnimap-request-accept-article group nil t))))
+      (nnimap-delete-article (list article))
+      ;; Return the new article number.
+      (cdr group-art))))
+
 (defun nnimap-add-cr ()
   (goto-char (point-min))
   (while (re-search-forward "\r?\n" nil t)