From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/83961 Path: news.gmane.org!not-for-mail From: Jan Tatarik Newsgroups: gmane.emacs.gnus.general Subject: FEATURE: icalendar - link to original gnus message from org entry Date: Thu, 12 Dec 2013 22:17:46 +0100 Message-ID: <87mwk5g45h.fsf@nb-jtatarik2.xing.hh> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1386883150 14534 80.91.229.3 (12 Dec 2013 21:19:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Dec 2013 21:19:10 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M32216@lists.math.uh.edu Thu Dec 12 22:19:15 2013 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VrDf8-0001Mt-A9 for ding-account@gmane.org; Thu, 12 Dec 2013 22:19:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1VrDdy-0003gB-Ju; Thu, 12 Dec 2013 15:18:02 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1VrDdx-0003g1-7b for ding@lists.math.uh.edu; Thu, 12 Dec 2013 15:18:01 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1VrDdv-0007HE-FK for ding@lists.math.uh.edu; Thu, 12 Dec 2013 15:18:00 -0600 Original-Received: from mail-bk0-f46.google.com ([209.85.214.46]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1VrDdt-0002p8-VE for ding@gnus.org; Thu, 12 Dec 2013 22:17:58 +0100 Original-Received: by mail-bk0-f46.google.com with SMTP id u15so1104675bkz.33 for ; Thu, 12 Dec 2013 13:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=ycmga+OzcuHSQW5HhukPLSTWm1wAtoGKPLxeBihvBEk=; b=cmd310t59AzkUZv9Oe4DjuhW4RDLJ25ASONcIn+Wyf6udEYyboQCWT7Qdtj0zN7Ez0 vtQpK28r4jtQyAEBAwkk8wclnHoWAEteNg8YEwepdabWT8Fo8y6h4UOlGTemz4wzwUe2 qlKuhxLUMdpgWHTdknl2wkYc+jScH2zLfz2XPs/FoLallGxRYrA9aQhJCfttFQpCdODb 0DHpcvqWO7VSdDPVR3zY2ESCIocdsCOBBbHY4djTGFHz7MQn5bx4y3SiKzMnbbLuhjCV a0mTuuJU1uqKYFxRbzKDbzYCfYOcq6QWoTU5MpC/hRrU3suIDnEd0a+Uvcb0cR9rbFLX UVlg== X-Received: by 10.205.105.193 with SMTP id dr1mr794216bkc.96.1386883072405; Thu, 12 Dec 2013 13:17:52 -0800 (PST) Original-Received: from nb-jtatarik2.xing.hh (e179225157.adsl.alicedsl.de. [85.179.225.157]) by mx.google.com with ESMTPSA id z6sm93902bkn.8.2013.12.12.13.17.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 12 Dec 2013 13:17:51 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Spam-Score: -3.0 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:83961 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=message-link.patch 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 + + * 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 * 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) --=-=-=--