After it's now possible for me to store an org link upon sending a message[1] I thought it might be even better to approach this problem in a more general way. The idea is to use `org-store-link' in message mode to create a link for the (yet to come) copy of the message. Currently `org-store-link' seems to be rather pointless in message mode as it creates a link to a draft (temporary) message file. Extending `org-gnus-store-link' to let it create a gnus link to the copy of the message when in message mode seems to be more reasonable. However, there are some, er, `issues' with this. 1) This will only work with Gnus. Message mode is in principle independent of Gnus but non-Gnus users will not benefit from `org-store-link' in message mode. 2) Storing a link in message mode effectively creates a link to something (the mail copy) that's (still) inexistent. This means that the link remains invalid until the message is actually sent (or more precisely: the copy is created upon sending). Furthermore, the link will be invalid if - the message is not sent; - the Gcc header is modified to point to a different group; - the message id is changed. And of course, the link description will be incorrect if Subject, From and/or To headers are changed between calling `org-store-link' and creating the message's copy. If you think --despite of those issues-- it's worth adding the creation of gnus links while in message mode I could provide a patch. I'd probably add the functionality to `org-gnus-store-link' but I'm not an org code expert and a different location may be more appropriate. What do you think? Ulf References: [1] see http://thread.gmane.org/gmane.emacs.orgmode/31280
Ulf Stegemann <ulf-news@zeitform.de> writes:
Hi Ulf,
> If you think --despite of those issues-- it's worth adding the
> creation of gnus links while in message mode I could provide a patch.
I'm curious how you are able to determine where a message will be filed
after sending it off. I mean, you neither have the Message-Id at that
point (unless that's added to `message-generate-headers-first'), nor do
you know the correct group, at least if there are more than one in the
Gcc header.
Bye,
Tassilo
Hi Tassilo, Tassilo Horn <tassilo@member.fsf.org> wrote: >> If you think --despite of those issues-- it's worth adding the >> creation of gnus links while in message mode I could provide a patch. > > I'm curious how you are able to determine where a message will be filed > after sending it off. I mean, you neither have the Message-Id at that > point (unless that's added to `message-generate-headers-first'), Touché, good point. I had set `message-generate-headers-first' to t ages ago, so obviously I didn't realise that this is not the default. You are absolutely right that generating the Message-ID during message setup is a perquisite for creating a link. It's probably better, to grab all necessary headers after the message has been sent (and that's what I originally did). But this means we cannot use `org-store-link' in message mode and is also impractical when using `gnus-delay-article'. Hmmm, thinking about it, maybe `org-store-link' could create the Message-ID and insert it if it's not already present. I should have a look. > nor do you know the correct group, at least if there are more than one > in the Gcc header. With multiple groups in Gcc I currently use the last one ... but it could also be the first one, all, a user specified or whatever else seems feasible. Ulf
Tassilo Horn <tassilo@member.fsf.org> writes:
> Ulf Stegemann <ulf-news@zeitform.de> writes:
>
>> If you think --despite of those issues-- it's worth adding the
>> creation of gnus links while in message mode I could provide a patch.
>
> I'm curious how you are able to determine where a message will be filed
> after sending it off. I mean, you neither have the Message-Id at that
> point (unless that's added to `message-generate-headers-first'), nor do
> you know the correct group, at least if there are more than one in the
> Gcc header.
There is a facility in Gnus called <info:(gnus)The Gnus Registry>
which I havn't investigated yet but it looks promising. From what I've
browsed the info it looks like it registers all the message ids and
remembers the folders. So it would be enough to remember the MID and
then make Gnus find it.
--
Miłego dnia,
Łukasz Stelmach
Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
Hi Łukasz,
>>> If you think --despite of those issues-- it's worth adding the
>>> creation of gnus links while in message mode I could provide a
>>> patch.
>>
>> I'm curious how you are able to determine where a message will be
>> filed after sending it off. I mean, you neither have the Message-Id
>> at that point (unless that's added to
>> `message-generate-headers-first'), nor do you know the correct group,
>> at least if there are more than one in the Gcc header.
>
> There is a facility in Gnus called <info:(gnus)The Gnus Registry>
> which I havn't investigated yet but it looks promising. From what I've
> browsed the info it looks like it registers all the message ids and
> remembers the folders. So it would be enough to remember the MID and
> then make Gnus find it.
But I think a user needs to enable that explicitly, so one cannot rely
on this feature being available... And the user has to setup
`gnus-refer-article-method' properly...
,----[ (info "(gnus)Registry Article Refer Method") ]
| The `nnregistry' refer method does exactly that. It has the
| advantage that an article may be found regardless of the group it's
| in--provided its `Message-ID' is known to the registry. It can be
| enabled by augmenting the start-up file with something along these
| lines:
|
| ;; Keep enough entries to have a good hit rate when referring to an
| ;; article using the registry. Use long group names so that Gnus
| ;; knows where the article is.
| (setq gnus-registry-max-entries 2500
| gnus-registry-use-long-group-names t)
|
| (gnus-registry-initialize)
|
| (setq gnus-refer-article-method
| '(current
| (nnregistry)
| (nnweb "gmane" (nnweb-type gmane))))
`----
Bye,
Tassilo
Tassilo Horn <tassilo@member.fsf.org> writes: > Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes: > >>>> If you think --despite of those issues-- it's worth adding the >>>> creation of gnus links while in message mode I could provide a >>>> patch. >>> >>> I'm curious how you are able to determine where a message will be >>> filed after sending it off. I mean, you neither have the Message-Id >>> at that point (unless that's added to >>> `message-generate-headers-first'), nor do you know the correct group, >>> at least if there are more than one in the Gcc header. >> >> There is a facility in Gnus called <info:(gnus)The Gnus Registry> >> which I havn't investigated yet but it looks promising. From what I've >> browsed the info it looks like it registers all the message ids and >> remembers the folders. So it would be enough to remember the MID and >> then make Gnus find it. > > ,----[ (info "(gnus)Registry Article Refer Method") ] [...] > `---- I haven't seen this piece yet. Interesting. > But I think a user needs to enable that explicitly, so one cannot rely > on this feature being available... And the user has to setup > `gnus-refer-article-method' properly... And install Gnus and Emacs too ;-) Of course the default setup not necessarily provide for what we are talking about. But it doesn't either way and the registry looks as a cleaner solution (however, I am not sure yet how to set it up on several machines in parallel) then noting Gcc during sending. There is no simple solution to this. By simple I mean "available without touching anything ousite org-mode". Theoretically org-mode could implement a function that searches through Gnus' database but thats against the DRY principle since such code itself exists in Gnus it just needs to be configured. -- Miłego dnia, Łukasz Stelmach
Hi Ulf, Ulf Stegemann <ulf-news@zeitform.de> writes: > If you think --despite of those issues-- it's worth adding the creation > of gnus links while in message mode I could provide a patch. FWIW, I think it would be useful. > I'd probably add the functionality to `org-gnus-store-link' but I'm > not an org code expert and a different location may be more > appropriate. What do you think? Such a change belongs to `org-gnus-store-link' -- I'd be glad to apply a patch to this effect. Thanks! -- Bastien
[-- Attachment #1: Type: text/plain, Size: 1059 bytes --] Bastien <bastien.guerry@wikimedia.fr> wrote: > Ulf Stegemann <ulf-news@zeitform.de> writes: > >> If you think --despite of those issues-- it's worth adding the creation >> of gnus links while in message mode I could provide a patch. > > FWIW, I think it would be useful. > >> I'd probably add the functionality to `org-gnus-store-link' but I'm >> not an org code expert and a different location may be more >> appropriate. What do you think? > > Such a change belongs to `org-gnus-store-link' -- I'd be glad to apply a > patch to this effect. Please find a patch attached. I works for me with latest Emacs, Org, Gnus from bzr/git but with all the limitations mentioned earlier in this thread. The patch includes the generation of the `Message-ID' header if none is present. It also removes the `message-deletable' property from that header to prevent Gnus from re-generating the message id and thus breaking the org link. This should (hopefully) work regardless of the value of `message-generate-headers-first', `message-deletable-headers' et al. Ulf [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: org-gnus-store-link-message-mode.diff --] [-- Type: text/x-patch, Size: 1793 bytes --] --- org-gnus.el.orig 2011-02-09 10:20:37.003314968 +0100 +++ org-gnus.el 2011-02-09 14:50:55.320440970 +0100 @@ -186,7 +186,35 @@ link (org-gnus-article-link group newsgroups message-id x-no-archive)) (org-add-link-props :link link :description desc) - link)))) + link)) + ((eq major-mode 'message-mode) + (setq org-store-link-plist nil) ; reset + (save-excursion + (save-restriction + (message-narrow-to-headers) + (and (not (message-fetch-field "Message-ID")) + (message-generate-headers '(Message-ID))) + (goto-char (point-min)) + (re-search-forward "^Message-ID: *.*$" nil t) + (put-text-property (match-beginning 0) (match-end 0) 'message-deletable nil) + (let ((gcc (car (last + (message-unquote-tokens + (message-tokenize-header (mail-fetch-field "gcc" nil t) " ,"))))) + (id (org-remove-angle-brackets (mail-fetch-field "Message-ID"))) + (to (mail-fetch-field "To")) + (from (mail-fetch-field "From")) + (subject (mail-fetch-field "Subject")) + desc link + newsgroup xarchive) ; those are always nil for gcc + (and (not gcc) + (error "Can not create link: No Gcc header found.")) + (org-store-link-props :type "gnus" :from from :subject subject + :message-id id :group gcc :to to) + (setq desc (org-email-link-description) + link (org-gnus-article-link + gcc newsgroup id xarchive)) + (org-add-link-props :link link :description desc) + link)))))) (defun org-gnus-open-nntp (path) "Follow the nntp: link specified by PATH." [-- Attachment #3: Type: text/plain, Size: 201 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Bastien <bastien.guerry@wikimedia.fr> writes:
> Such a change belongs to `org-gnus-store-link' -- I'd be glad to apply a
> patch to this effect.
Ulf sent me a patch that I just applied.
It allows Gnusers to create org-links from message-mode.
This is a move toward a more general solution "org-message.el",
handling not only Gnus but any Emacs MUA storing sent messages,
ideas and patches welcome.
Note that the link will not find drafts, just sent emails.
Thanks to Ulf for this contribution, quite useful!
--
Bastien