From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?C=E9dric_Ch=E9pied?= Subject: Wanderlust and org-capture Date: Fri, 23 Jan 2015 08:59:31 +0100 Message-ID: <54c1ff70.0308c20a.36d7.4d34@mx.google.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEZ9j-0007vI-09 for emacs-orgmode@gnu.org; Fri, 23 Jan 2015 02:59:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEZ9e-0004Y5-SA for emacs-orgmode@gnu.org; Fri, 23 Jan 2015 02:59:50 -0500 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:37338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEZ9e-0004Y1-H6 for emacs-orgmode@gnu.org; Fri, 23 Jan 2015 02:59:46 -0500 Received: by mail-wi0-f181.google.com with SMTP id fb4so929651wid.2 for ; Thu, 22 Jan 2015 23:59:45 -0800 (PST) Received: from Zorglub.gmail.com (LPoitiers-656-1-50-32.w90-63.abo.wanadoo.fr. [90.63.131.32]) by mx.google.com with ESMTPSA id n3sm1085304wja.36.2015.01.22.23.59.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 23:59:44 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, I'm using wanderlust to read and write emails in emacs. I wanted to use org-capture to add TODOs in my org files. In org-capture-templates documentation there is a line talking about wanderlust (I think): vm, wl, mh, mew, rmail, | %:type %:subject %:message-id But I was unable to use %:type or %:whatever in my template to capture wanderlust messages. I found an org-rmail.el file in org-mode sources but I couldn't find org-wl.el and I assumed this is the reason why I can't use org-capture. I wrote an org-wl.el file based on org-rmail. you can find sources here: https://github.com/chep/org-wl Feel free to comment it and to use it if you want. ;;; org-wl.el --- Support for links to Wanderlust messages from within Org-mode ;; Copyright (C) 2014 Cédric Chépied ;; Author: Cédric Chépied ;; Keywords: org, wanderlust, link ;; Homepage: http://orgmode.org ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Template example: ;; (add-to-list 'org-capture-templates '(("e" "Email Todo" entry ;; (file+headline "~/org/myfile.org" "Tasks") ;; "* TODO %^{Brief Description}\nEmail: %a\nFrom: %:from \nTo: %:to \n%?Added: %U\n" :prepend t))) ;;; Code: (require 'org) ;; Declare external functions and variables (declare-function elmo-folder-name-internal "elmo" (ENTITY)) (declare-function wl-summary-message-number "wl-summary" ()) (declare-function wl-summary-set-message-buffer-or-redisplay "wl-summary" (&rest ARGS)) (declare-function wl-summary-redisplay-internal "wl-summary" (&optional FOLDER NUMBER FORCE-RELOAD MIME-MODE HEADER-MODE)) (declare-function wl-folder-get-elmo-folder "wl-folder" (ENTITY &optional NO-CACHE)) (org-add-link-type "wl" 'org-wl-open) (add-hook 'org-store-link-functions 'org-wl-store-link) (defun org-wl-store-link () "Store a link to a wl folder or message." (when (eq major-mode 'wl-summary-mode) (let ((folder (elmo-folder-name-internal wl-summary-buffer-elmo-folder)) (message-id (wl-summary-message-number))) (save-excursion (wl-summary-set-message-buffer-or-redisplay) (let* ((from (mail-fetch-field "from")) (to (mail-fetch-field "to")) (subject (mail-fetch-field "subject")) (date (mail-fetch-field "date")) (date-ts (and date (format-time-string (org-time-stamp-format t) (date-to-time date)))) (date-ts-ia (and date (format-time-string (org-time-stamp-format t t) (date-to-time date)))) link) (org-store-link-props :type "wl" :from from :to to :subject subject :message-id message-id) (when date (org-add-link-props :date date :date-timestamp date-ts :date-timestamp-inactive date-ts-ia)) (setq link (concat "wl:" folder "#" (number-to-string message-id))) (org-add-link-props :link link :description subject) link))))) (defun org-wl-open (path) "Follow a wl message link to the specified PATH." (unless (string-match "\\(.*\\)#\\([0-9]+\\)" path) (error "Error in wl link")) (let* ((folder (match-string 1 path)) (msg (string-to-number (match-string 2 path))) (elmo-folder (wl-folder-get-elmo-folder folder))) (wl-summary-redisplay-internal elmo-folder msg) )) (provide 'org-wl) ;;; org-wl.el ends here -- Cédric Chépied