From: Jan Tatarik <jan.tatarik@gmail.com>
To: ding@gnus.org
Subject: FEATURE: icalendar - link to original gnus message from org entry
Date: Thu, 12 Dec 2013 22:17:46 +0100 [thread overview]
Message-ID: <87mwk5g45h.fsf@nb-jtatarik2.xing.hh> (raw)
[-- Attachment #1: Type: text/plain, Size: 226 bytes --]
On Wed, Nov 27 2013, Mario Peter wrote:
> Hi again,
> it be cool to have a back link to the gnus message in the org entry
> beeing created from gnus article. What do you think?
This patch implements the requested feature.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: message-link.patch --]
[-- Type: text/x-diff, Size: 5711 bytes --]
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b747f7c6f74850a2a533ec3728477053962b4dba..43cdc73bb7d8a3fc8ff6cd135114b23e6c0e24d3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2013-12-12 Jan Tatarik <jan.tatarik@gmail.com>
+
+ * gnus-icalendar.el (gnus-icalendar--update-org-event)
+ (gnus-icalendar-event->org-entry)
+ (gnus-icalendar--update-org-event)
+ (gnus-icalendar:org-event-save)
+ (gnus-icalendar-event:sync-to-org, gnus-icalendar-reply)
+ (gnus-icalendar-sync-event-to-org, gnus-icalendar-mm-inline):
+ Include org link to the original message when syncing events to
+ org.
+
2013-12-08 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-msg.el (gnus-setup-message): Fix the type of argument passed to
diff --git a/lisp/gnus-icalendar.el b/lisp/gnus-icalendar.el
index 5f152921b663850918be8bfcb3a76f5e69bc1d6d..eb79ba119c04516ade363ad3ef9dbe35079be4fe 100644
--- a/lisp/gnus-icalendar.el
+++ b/lisp/gnus-icalendar.el
@@ -441,7 +441,7 @@ Return nil for non-recurring EVENT."
(mapconcat #'identity participants ", "))
;; TODO: make the template customizable
-(defmethod gnus-icalendar-event->org-entry ((event gnus-icalendar-event) reply-status)
+(defmethod gnus-icalendar-event->org-entry ((event gnus-icalendar-event) reply-status message-link)
"Return string with new `org-mode' entry describing EVENT."
(with-temp-buffer
(org-mode)
@@ -466,6 +466,10 @@ Return nil for non-recurring EVENT."
(org-entry-put (point) (car prop) (cdr prop)))
props))
+ (insert " ")
+ (org-insert-link nil message-link "Show the original message")
+ (insert "\n\n")
+
(when description
(save-restriction
(narrow-to-region (point) (point))
@@ -511,7 +515,7 @@ is searched."
(org-show-entry))))
-(defun gnus-icalendar--update-org-event (event reply-status &optional org-file)
+(defun gnus-icalendar--update-org-event (event reply-status message-link &optional org-file)
(let ((file (gnus-icalendar-find-org-event-file event org-file)))
(when file
(with-current-buffer (find-file-noselect file)
@@ -546,6 +550,12 @@ is searched."
(forward-line)
(delete-region (point) entry-end))
+ (insert "\n")
+ (org-insert-link nil message-link "Show the original message")
+ (indent-region (line-beginning-position) (line-end-position)
+ (1+ entry-outline-level))
+ (insert "\n")
+
;; put new event description in the entry body
(when description
(save-restriction
@@ -608,9 +618,9 @@ is searched."
;; org-capture-templates-contexts))
))
-(defun gnus-icalendar:org-event-save (event reply-status)
+(defun gnus-icalendar:org-event-save (event reply-status message-link)
(with-temp-buffer
- (org-capture-string (gnus-icalendar-event->org-entry event reply-status)
+ (org-capture-string (gnus-icalendar-event->org-entry event reply-status message-link)
gnus-icalendar-org-template-key)))
(defun gnus-icalendar-show-org-agenda (event)
@@ -622,12 +632,12 @@ is searched."
(org-agenda-list nil (gnus-icalendar-event:start event) duration-days)))
-(defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-request) reply-status)
+(defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-request) reply-status message-link)
(if (gnus-icalendar-find-org-event-file event)
- (gnus-icalendar--update-org-event event reply-status)
- (gnus-icalendar:org-event-save event reply-status)))
+ (gnus-icalendar--update-org-event event reply-status message-link)
+ (gnus-icalendar:org-event-save event reply-status message-link)))
-(defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-cancel) reply-status)
+(defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-cancel) reply-status message-link)
(when (gnus-icalendar-find-org-event-file event)
(gnus-icalendar--cancel-org-event event)))
@@ -677,6 +687,9 @@ only makes sense to define names or email addresses."
(make-variable-buffer-local
(defvar gnus-icalendar-handle nil))
+(make-variable-buffer-local
+ (defvar gnus-icalendar-message-link nil))
+
(defvar gnus-icalendar-identities
(apply #'append
(mapcar (lambda (x) (if (listp x) x (list x)))
@@ -786,13 +799,13 @@ only makes sense to define names or email addresses."
;; Back in article buffer
(setq-local gnus-icalendar-reply-status status)
(when gnus-icalendar-org-enabled-p
- (gnus-icalendar--update-org-event event status)
+ (gnus-icalendar--update-org-event event status gnus-icalendar-message-link)
;; refresh article buffer to update the reply status
(with-current-buffer gnus-summary-buffer
(gnus-summary-show-article))))))))
(defun gnus-icalendar-sync-event-to-org (event)
- (gnus-icalendar-event:sync-to-org event gnus-icalendar-reply-status))
+ (gnus-icalendar-event:sync-to-org event gnus-icalendar-reply-status gnus-icalendar-message-link))
(defmethod gnus-icalendar-event:inline-reply-buttons ((event gnus-icalendar-event) handle)
(when (gnus-icalendar-event:rsvp event)
@@ -841,6 +854,7 @@ only makes sense to define names or email addresses."
(let ((event (gnus-icalendar-event-from-handle handle gnus-icalendar-identities)))
(setq gnus-icalendar-reply-status nil)
+ (setq-local gnus-icalendar-message-link (org-gnus-store-link))
(when event
(gmm-labels ((insert-button-group (buttons)
next reply other threads:[~2013-12-12 21:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 21:17 Jan Tatarik [this message]
2013-12-18 21:12 ` Adam Sjøgren
2013-12-19 20:12 ` Jan Tatarik
2013-12-26 15:51 ` Lars Ingebrigtsen
2013-12-26 22:10 ` Steinar Bang
2013-12-26 22:39 ` Katsumi Yamaoka
2013-12-27 3:30 ` Lars Ingebrigtsen
2013-12-27 8:32 ` Steinar Bang
2013-12-26 22:40 ` Jan Tatarik
2014-02-01 0:34 ` Lars Ingebrigtsen
2014-02-02 11:20 ` Jan Tatarik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwk5g45h.fsf@nb-jtatarik2.xing.hh \
--to=jan.tatarik@gmail.com \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).