emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102023: Allow nnimap article editing


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102023: Allow nnimap article editing (sort of).
Date: Thu, 21 Oct 2010 01:23:34 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102023
author: Lars Magne Ingebrigtsen <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Thu 2010-10-21 01:23:34 +0000
message:
  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.
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/gnus-sum.el
  lisp/gnus/mm-decode.el
  lisp/gnus/nnimap.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-10-21 00:27:32 +0000
+++ b/lisp/gnus/ChangeLog       2010-10-21 01:23:34 +0000
@@ -1,3 +1,10 @@
+2010-10-21  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * 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  <address@hidden>
 
        * nnrss.el (nnrss-wash-html-in-text-plain-parts): Remove.

=== modified file 'lisp/gnus/gnus-sum.el'
--- a/lisp/gnus/gnus-sum.el     2010-10-17 00:04:06 +0000
+++ b/lisp/gnus/gnus-sum.el     2010-10-21 01:23:34 +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))))))

=== modified file 'lisp/gnus/mm-decode.el'
--- a/lisp/gnus/mm-decode.el    2010-10-20 22:29:38 +0000
+++ b/lisp/gnus/mm-decode.el    2010-10-21 01:23:34 +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)))

=== modified file 'lisp/gnus/nnimap.el'
--- a/lisp/gnus/nnimap.el       2010-10-20 22:29:38 +0000
+++ b/lisp/gnus/nnimap.el       2010-10-21 01:23:34 +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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]