Gnus development mailing list
 help / color / mirror / Atom feed
* article editing in nnimap
@ 2010-09-20  1:09 Dan Christensen
  2010-09-21 21:30 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Christensen @ 2010-09-20  1:09 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]

With the old version on nnimap, I had a hack in place that allowed
article editing; but it wasn't ready for others, because it didn't
update the summary buffer correctly or preserve marks.

It seems to me that this shouldn't be such a hard thing to support
properly, though.  Gnus can already move an article between groups, and
editing an article in a backend that has immutable articles is like
moving it to the same group, except that the article is changed before
being saved to the group.

So I think it should be possible to re-use the code that is invoked when
the user types `B m'.  An extra argument (or a global variable) could
be used to tell nnimap-request-move-article that the move isn't
to be considered internal and to tell nnimap-request-accept-buffer
to take the article from the editing buffer.  That already would be
a big step forward, but even better would be to update the summary
buffer to replace the deleted article with the newly created article.

Here's a crude patch against the old nnimap that illustrates the idea,
but which doesn't work.  But maybe something similar will work with the
new nnimap (and maybe it would only be 10 or 20 lines of code)?

(And maybe this can even be done independent of the backend, just
assuming that the backend can create articles?)

Dan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap-reuse-move.patch --]
[-- Type: text/x-diff, Size: 2754 bytes --]

--- nnimap.orig.el	2009-09-30 12:56:46.000000000 -0400
+++ nnimap-nogood.el	2009-10-24 20:42:16.000000000 -0400
@@ -52,7 +52,6 @@
 ;;   o IMAP2BIS compatibility? (RFC2061)
 ;;   o ACAP stuff (perhaps a different project, would be nice to ACAPify
 ;;     .newsrc.eld)
-;;   o What about Gnus's article editing, can we support it?  NO!
 ;;   o Use \Draft to support the draft group??
 ;;   o Duplicate suppression
 ;;   o Rewrite UID SEARCH UID X as UID FETCH X (UID) for those with slow servers
@@ -1564,6 +1563,7 @@ (deffoo nnimap-request-move-article (art
 	    (nnimap-current-move-article article)
 	    (nnimap-current-move-group group)
 	    (nnimap-current-move-server nnimap-current-server)
+	    (move-is-internal (and move-is-internal (not nnimap-request-accept-buffer)))
 	    result)
 	(gnus-message 10 "nnimap-request-move-article: this is an %s move"
 		      (if move-is-internal
@@ -1584,6 +1584,7 @@ (deffoo nnimap-request-move-article (art
 	      "\\Deleted" 'silent nnimap-server-buffer))
 	result))))
 
+(setq nnimap-request-accept-buffer nil)
 (deffoo nnimap-request-accept-article (group &optional server last)
   (when (nnimap-possibly-change-server server)
     (let (uid)
@@ -1596,7 +1597,7 @@ (deffoo nnimap-request-accept-article (g
 					     nnimap-current-move-article)
 					    group 'dontcreate nil
 					    nnimap-server-buffer))
-		  (with-current-buffer (current-buffer)
+		  (with-current-buffer (or nnimap-request-accept-buffer (current-buffer))
 		    (goto-char (point-min))
 		    ;; remove any 'From blabla' lines, some IMAP servers
 		    ;; reject the entire message otherwise.
@@ -1619,6 +1620,16 @@ (deffoo nnimap-request-accept-article (g
 	  (cons group (nth 1 uid))
 	(nnheader-report 'nnimap (imap-error-text nnimap-server-buffer))))))
 
+(deffoo nnimap-request-replace-article (article group buffer)
+  (let ((nnimap-request-accept-buffer buffer)
+	(gnusgroup (gnus-group-prefixed-name
+		    group (gnus-server-to-method
+			   (format "nnimap:%s" nnimap-current-server)))))
+    ; With or without the next line I get a backtrace, but it changes:
+    ;(nnimap-request-article article group)
+    (message "%s" (list article group nnimap-request-accept-buffer gnusgroup))
+    (gnus-summary-move-article 1 gnusgroup)))
+
 (deffoo nnimap-request-delete-group (group force &optional server)
   (when (nnimap-possibly-change-server server)
     (when (string= group (imap-current-mailbox nnimap-server-buffer))
@@ -1789,6 +1800,7 @@ (defun nnimap-mark-permanent-p (mark &op
 	  nnimap-request-expire-articles
 	  nnimap-request-move-article
 	  nnimap-request-accept-article
+	  nnimap-request-replace-article
 	  nnimap-request-delete-group
 	  nnimap-request-rename-group
 	  gnus-group-nnimap-expunge

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-20  1:09 article editing in nnimap Dan Christensen
@ 2010-09-21 21:30 ` Lars Magne Ingebrigtsen
  2010-09-21 22:24   ` Dan Christensen
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-21 21:30 UTC (permalink / raw)
  To: ding

Dan Christensen <jdc@uwo.ca> writes:

> So I think it should be possible to re-use the code that is invoked when
> the user types `B m'.  An extra argument (or a global variable) could
> be used to tell nnimap-request-move-article that the move isn't
> to be considered internal and to tell nnimap-request-accept-buffer
> to take the article from the editing buffer.  That already would be
> a big step forward, but even better would be to update the summary
> buffer to replace the deleted article with the newly created article.

Well, calling -request-accept-article, and then deleting the old one
would sort of get you most of the way there, wouldn't it?
-request-accept-article returns the group/article number, so it'd kinda
be just

* request the article to a buffer
* call request-accept
* delete the previous article
* jump to the new article number in the summary buffer, which will request
the header for the "new" article.

Although you'd then have two entries in the thread with the same
Message-ID, which may freak out the threading code...  or not.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-21 21:30 ` Lars Magne Ingebrigtsen
@ 2010-09-21 22:24   ` Dan Christensen
  2010-09-21 22:52     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Christensen @ 2010-09-21 22:24 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Dan Christensen <jdc@uwo.ca> writes:
>
>> [stuff about editing when articles are immutable]
>
> Well, calling -request-accept-article, and then deleting the old one
> would sort of get you most of the way there, wouldn't it?
> -request-accept-article returns the group/article number, so it'd kinda
> be just
>
> * request the article to a buffer
> * call request-accept

You'd need to transfer the marks over, right?  Does `B m' do anything
else that would need to be done?

> * delete the previous article

Could it's summary line be removed too?

> * jump to the new article number in the summary buffer, which will request
> the header for the "new" article.

Over, this sounds reasonable to me.  And easily doable by someone who
knows the code, right?  :-)

Dan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-21 22:24   ` Dan Christensen
@ 2010-09-21 22:52     ` Lars Magne Ingebrigtsen
  2010-09-21 23:01       ` Dan Christensen
  2010-09-22 13:37       ` Ted Zlatanov
  0 siblings, 2 replies; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-21 22:52 UTC (permalink / raw)
  To: ding

Dan Christensen <jdc@uwo.ca> writes:

> You'd need to transfer the marks over, right?  Does `B m' do anything
> else that would need to be done?

Yeah, marks...  perhaps having a version of -copy-article that takes a
buffer as its argument in addition to the article number would be
easier?  Then the marks would follow automatically.

> Could it's summary line be removed too?

Yes, we could narrow to a limit excluding that article.

> Over, this sounds reasonable to me.  And easily doable by someone who
> knows the code, right?  :-)

:-)

Perhaps once the nnimap fallout is over...

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-21 22:52     ` Lars Magne Ingebrigtsen
@ 2010-09-21 23:01       ` Dan Christensen
  2010-09-22 13:37       ` Ted Zlatanov
  1 sibling, 0 replies; 8+ messages in thread
From: Dan Christensen @ 2010-09-21 23:01 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Dan Christensen <jdc@uwo.ca> writes:
>
>> You'd need to transfer the marks over, right?  Does `B m' do anything
>> else that would need to be done?
>
> Yeah, marks...  perhaps having a version of -copy-article that takes a
> buffer as its argument in addition to the article number would be
> easier?  Then the marks would follow automatically.

That sounds similar to my original idea.  I tried something like that in
the patch that started this thread, but I couldn't get it to work.
(Instead of changing the calling signature, I used a global variable as
a quick hack.  And it was -accept-article that I tried to change, to get
it to use the editing buffer instead of the current buffer.)

Dan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-21 22:52     ` Lars Magne Ingebrigtsen
  2010-09-21 23:01       ` Dan Christensen
@ 2010-09-22 13:37       ` Ted Zlatanov
  2010-09-22 16:49         ` Lars Magne Ingebrigtsen
  2010-09-22 17:45         ` Dan Christensen
  1 sibling, 2 replies; 8+ messages in thread
From: Ted Zlatanov @ 2010-09-22 13:37 UTC (permalink / raw)
  To: ding

On Wed, 22 Sep 2010 00:52:06 +0200 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> Dan Christensen <jdc@uwo.ca> writes:
>> You'd need to transfer the marks over, right?  Does `B m' do anything
>> else that would need to be done?

LMI> Yeah, marks...  perhaps having a version of -copy-article that takes a
LMI> buffer as its argument in addition to the article number would be
LMI> easier?  Then the marks would follow automatically.

I don't see (but perhaps I've missed it in the discussion) why not just
implement -replace-article (maybe it can use -copy-article internally)?
Then editing with `gnus-request-replace-article' will Just Work (with
`e' in the summary buffer for instance).

Ted




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-22 13:37       ` Ted Zlatanov
@ 2010-09-22 16:49         ` Lars Magne Ingebrigtsen
  2010-09-22 17:45         ` Dan Christensen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-22 16:49 UTC (permalink / raw)
  To: ding

Ted Zlatanov <tzz@lifelogs.com> writes:

> I don't see (but perhaps I've missed it in the discussion) why not just
> implement -replace-article (maybe it can use -copy-article internally)?
> Then editing with `gnus-request-replace-article' will Just Work (with
> `e' in the summary buffer for instance).

Yes, this was about how to implement -replace-article, really.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: article editing in nnimap
  2010-09-22 13:37       ` Ted Zlatanov
  2010-09-22 16:49         ` Lars Magne Ingebrigtsen
@ 2010-09-22 17:45         ` Dan Christensen
  1 sibling, 0 replies; 8+ messages in thread
From: Dan Christensen @ 2010-09-22 17:45 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

Ted Zlatanov <tzz@lifelogs.com> writes:

> I don't see (but perhaps I've missed it in the discussion) why not just
> implement -replace-article (maybe it can use -copy-article internally)?

That's what my proposal is, as suggested in the original (non-working)
patch against the old nnimap.el (included again below).

In short, when asked to replace an article, nnimap could instead move
the article from the group to the same group, but instead of using
the old buffer, use the edited buffer.

Dan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap-reuse-move.patch --]
[-- Type: text/x-diff, Size: 2754 bytes --]

--- nnimap.orig.el	2009-09-30 12:56:46.000000000 -0400
+++ nnimap-nogood.el	2009-10-24 20:42:16.000000000 -0400
@@ -52,7 +52,6 @@
 ;;   o IMAP2BIS compatibility? (RFC2061)
 ;;   o ACAP stuff (perhaps a different project, would be nice to ACAPify
 ;;     .newsrc.eld)
-;;   o What about Gnus's article editing, can we support it?  NO!
 ;;   o Use \Draft to support the draft group??
 ;;   o Duplicate suppression
 ;;   o Rewrite UID SEARCH UID X as UID FETCH X (UID) for those with slow servers
@@ -1564,6 +1563,7 @@ (deffoo nnimap-request-move-article (art
 	    (nnimap-current-move-article article)
 	    (nnimap-current-move-group group)
 	    (nnimap-current-move-server nnimap-current-server)
+	    (move-is-internal (and move-is-internal (not nnimap-request-accept-buffer)))
 	    result)
 	(gnus-message 10 "nnimap-request-move-article: this is an %s move"
 		      (if move-is-internal
@@ -1584,6 +1584,7 @@ (deffoo nnimap-request-move-article (art
 	      "\\Deleted" 'silent nnimap-server-buffer))
 	result))))
 
+(setq nnimap-request-accept-buffer nil)
 (deffoo nnimap-request-accept-article (group &optional server last)
   (when (nnimap-possibly-change-server server)
     (let (uid)
@@ -1596,7 +1597,7 @@ (deffoo nnimap-request-accept-article (g
 					     nnimap-current-move-article)
 					    group 'dontcreate nil
 					    nnimap-server-buffer))
-		  (with-current-buffer (current-buffer)
+		  (with-current-buffer (or nnimap-request-accept-buffer (current-buffer))
 		    (goto-char (point-min))
 		    ;; remove any 'From blabla' lines, some IMAP servers
 		    ;; reject the entire message otherwise.
@@ -1619,6 +1620,16 @@ (deffoo nnimap-request-accept-article (g
 	  (cons group (nth 1 uid))
 	(nnheader-report 'nnimap (imap-error-text nnimap-server-buffer))))))
 
+(deffoo nnimap-request-replace-article (article group buffer)
+  (let ((nnimap-request-accept-buffer buffer)
+	(gnusgroup (gnus-group-prefixed-name
+		    group (gnus-server-to-method
+			   (format "nnimap:%s" nnimap-current-server)))))
+    ; With or without the next line I get a backtrace, but it changes:
+    ;(nnimap-request-article article group)
+    (message "%s" (list article group nnimap-request-accept-buffer gnusgroup))
+    (gnus-summary-move-article 1 gnusgroup)))
+
 (deffoo nnimap-request-delete-group (group force &optional server)
   (when (nnimap-possibly-change-server server)
     (when (string= group (imap-current-mailbox nnimap-server-buffer))
@@ -1789,6 +1800,7 @@ (defun nnimap-mark-permanent-p (mark &op
 	  nnimap-request-expire-articles
 	  nnimap-request-move-article
 	  nnimap-request-accept-article
+	  nnimap-request-replace-article
 	  nnimap-request-delete-group
 	  nnimap-request-rename-group
 	  gnus-group-nnimap-expunge

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-09-22 17:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-20  1:09 article editing in nnimap Dan Christensen
2010-09-21 21:30 ` Lars Magne Ingebrigtsen
2010-09-21 22:24   ` Dan Christensen
2010-09-21 22:52     ` Lars Magne Ingebrigtsen
2010-09-21 23:01       ` Dan Christensen
2010-09-22 13:37       ` Ted Zlatanov
2010-09-22 16:49         ` Lars Magne Ingebrigtsen
2010-09-22 17:45         ` Dan Christensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).