emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Wanderlust and org-capture
@ 2015-01-23  7:59 Cédric Chépied
  2015-01-23 19:32 ` Marco Wahl
  0 siblings, 1 reply; 4+ messages in thread
From: Cédric Chépied @ 2015-01-23  7:59 UTC (permalink / raw)
  To: emacs-orgmode

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 <cedric.chepied@gmail.com>

;; Author: Cédric Chépied <cedric.chepied@gmail.com>
;; 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
<cedric.chepied@gmail.com>

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

* Re: Wanderlust and org-capture
  2015-01-23  7:59 Wanderlust and org-capture Cédric Chépied
@ 2015-01-23 19:32 ` Marco Wahl
  2015-01-26 11:03   ` Cédric Chépied
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Wahl @ 2015-01-23 19:32 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Cédric Chépied <cedric.chepied@gmail.com> writes:

> 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.

There is ./contrib/lisp/org-wl.el at least in the current master branch.

See (info "(org)Installation") for setting the load-path.  Then you can
activate module org-wl using M-x customize-variable org-modules.

> 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.

A comparison with the existing org-wl could be interesting.


HTH and best regards,  Marco
-- 
http://www.wahlzone.de
GPG: 0x49010A040A3AE6F2

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

* Re: Wanderlust and org-capture
  2015-01-23 19:32 ` Marco Wahl
@ 2015-01-26 11:03   ` Cédric Chépied
  2015-01-26 21:42     ` Marco Wahl
  0 siblings, 1 reply; 4+ messages in thread
From: Cédric Chépied @ 2015-01-26 11:03 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

At Fri, 23 Jan 2015 20:32:24 +0100,
Marco Wahl wrote:
> There is ./contrib/lisp/org-wl.el at least in the current master branch.

This file is not in my org files integrated in emacs. That's why I didn't find
it. Are there many differences between integrated org (emacs git repo), elpa
package and git repository?

> See (info "(org)Installation") for setting the load-path.  Then you can
> activate module org-wl using M-x customize-variable org-modules.

Thanks, I will try it.

> A comparison with the existing org-wl could be interesting.

I think the already existing file is better than mine because I don't know
wanderlust code.

Regards,
-- 
Cédric Chépied
<cedric.chepied@gmail.com>

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

* Re: Wanderlust and org-capture
  2015-01-26 11:03   ` Cédric Chépied
@ 2015-01-26 21:42     ` Marco Wahl
  0 siblings, 0 replies; 4+ messages in thread
From: Marco Wahl @ 2015-01-26 21:42 UTC (permalink / raw)
  To: emacs-orgmode

>> ... ./contrib/lisp/org-wl.el at least in the current master branch.
>
> This file is not in my org files integrated in emacs. That's why I didn't find
> it. Are there many differences between integrated org (emacs git repo), elpa
> package and git repository?

I think one can regard the contrib directory as a source of extra
modules.  With this view the difference between git orgmode and the elpa
orgmode package (and also the orgmode that comes with Emacs) is the
development that lies between the versions.  AFAICS the orgmode elpa
package is very close to the HEAD in the orgmode git repo.

IIRC the contrib directory is a place for experimentation.  The
modules might need further testing before they find their way into a
release.  Further there might be licensing issues.

BTW I just found http://orgmode.org/worg/org-contrib/ which has a list
of modules of the contrib directory.


Best regards,  Marco
-- 
http://www.wahlzone.de
GPG: 0x49010A040A3AE6F2

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

end of thread, other threads:[~2015-01-26 21:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23  7:59 Wanderlust and org-capture Cédric Chépied
2015-01-23 19:32 ` Marco Wahl
2015-01-26 11:03   ` Cédric Chépied
2015-01-26 21:42     ` Marco Wahl

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).