2008-03-21 12:10:23 -04:00
|
|
|
;;; org-wl.el --- Support for links to Wanderlust messages from within Org-mode
|
2008-03-14 13:22:03 -04:00
|
|
|
|
2009-01-26 03:42:33 -05:00
|
|
|
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
|
|
|
|
;; Free Software Foundation, Inc.
|
2008-03-14 13:22:03 -04:00
|
|
|
|
2008-04-10 03:00:12 -04:00
|
|
|
;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
|
2008-03-14 13:22:03 -04:00
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
|
|
|
;; Homepage: http://orgmode.org
|
2009-11-13 01:10:51 -05:00
|
|
|
;; Version: 6.33
|
2008-03-14 13:22:03 -04:00
|
|
|
;;
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;;
|
2008-05-06 08:45:52 -04:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2008-03-14 13:22:03 -04:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:45:52 -04:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2008-03-14 13:22:03 -04:00
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2008-05-06 08:45:52 -04:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2008-03-14 13:22:03 -04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
|
2008-03-21 12:10:23 -04:00
|
|
|
;; This file implements links to Wanderlust messages from within Org-mode.
|
2008-03-14 13:22:03 -04:00
|
|
|
;; Org-mode loads this module by default - if this is not what you want,
|
|
|
|
;; configure the variable `org-modules'.
|
|
|
|
|
2008-03-21 12:10:23 -04:00
|
|
|
;;; Code:
|
|
|
|
|
2008-03-14 13:22:03 -04:00
|
|
|
(require 'org)
|
|
|
|
|
2008-03-20 05:53:29 -04:00
|
|
|
(defgroup org-wl nil
|
|
|
|
"Options concerning the Wanderlust link."
|
|
|
|
:tag "Org Startup"
|
|
|
|
:group 'org-link)
|
|
|
|
|
|
|
|
(defcustom org-wl-link-to-refile-destination t
|
|
|
|
"Create a link to the refile destination if the message is marked as refile."
|
|
|
|
:group 'org-wl
|
|
|
|
:type 'boolean)
|
|
|
|
|
2008-03-14 13:22:03 -04:00
|
|
|
;; Declare external functions and variables
|
|
|
|
(declare-function elmo-folder-exists-p "ext:elmo" (folder) t)
|
|
|
|
(declare-function elmo-message-entity-field "ext:elmo-msgdb"
|
|
|
|
(entity field &optional type))
|
|
|
|
(declare-function elmo-message-field "ext:elmo"
|
|
|
|
(folder number field &optional type) t)
|
2008-04-06 14:39:40 -04:00
|
|
|
(declare-function elmo-msgdb-overview-get-entity "ext:elmo" (id msgdb) t)
|
2008-03-14 13:22:03 -04:00
|
|
|
;; Backward compatibility to old version of wl
|
2008-03-22 11:52:18 -04:00
|
|
|
(declare-function wl "ext:wl" () t)
|
2008-04-06 14:39:40 -04:00
|
|
|
(declare-function wl-summary-buffer-msgdb "ext:wl-folder" () t)
|
2008-03-14 13:22:03 -04:00
|
|
|
(declare-function wl-summary-jump-to-msg-by-message-id "ext:wl-summary"
|
|
|
|
(&optional id))
|
|
|
|
(declare-function wl-summary-line-from "ext:wl-summary" ())
|
|
|
|
(declare-function wl-summary-line-subject "ext:wl-summary" ())
|
|
|
|
(declare-function wl-summary-message-number "ext:wl-summary" ())
|
|
|
|
(declare-function wl-summary-redisplay "ext:wl-summary" (&optional arg))
|
2008-03-20 05:53:29 -04:00
|
|
|
(declare-function wl-summary-registered-temp-mark "ext:wl-action" (number))
|
2008-03-22 11:52:18 -04:00
|
|
|
(declare-function wl-folder-goto-folder-subr "ext:wl-folder"
|
|
|
|
(&optional folder sticky))
|
|
|
|
(defvar wl-init)
|
2008-03-14 13:22:03 -04:00
|
|
|
(defvar wl-summary-buffer-elmo-folder)
|
|
|
|
(defvar wl-summary-buffer-folder-name)
|
|
|
|
|
|
|
|
;; Install the link type
|
|
|
|
(org-add-link-type "wl" 'org-wl-open)
|
|
|
|
(add-hook 'org-store-link-functions 'org-wl-store-link)
|
|
|
|
|
|
|
|
;; Implementation
|
|
|
|
(defun org-wl-store-link ()
|
2008-03-21 12:10:23 -04:00
|
|
|
"Store a link to a WL folder or message."
|
2008-03-20 05:53:29 -04:00
|
|
|
(when (eq major-mode 'wl-summary-mode)
|
|
|
|
(let* ((msgnum (wl-summary-message-number))
|
|
|
|
(mark-info (wl-summary-registered-temp-mark msgnum))
|
|
|
|
(folder-name
|
|
|
|
(if (and org-wl-link-to-refile-destination
|
|
|
|
mark-info
|
|
|
|
(equal (nth 1 mark-info) "o")) ; marked as refile
|
|
|
|
(nth 2 mark-info)
|
|
|
|
wl-summary-buffer-folder-name))
|
2008-03-14 13:22:03 -04:00
|
|
|
(message-id (elmo-message-field wl-summary-buffer-elmo-folder
|
|
|
|
msgnum 'message-id))
|
|
|
|
(wl-message-entity
|
|
|
|
(if (fboundp 'elmo-message-entity)
|
|
|
|
(elmo-message-entity
|
|
|
|
wl-summary-buffer-elmo-folder msgnum)
|
|
|
|
(elmo-msgdb-overview-get-entity
|
|
|
|
msgnum (wl-summary-buffer-msgdb))))
|
|
|
|
(from (wl-summary-line-from))
|
2008-03-20 05:53:29 -04:00
|
|
|
(to (let ((to-field (elmo-message-entity-field wl-message-entity
|
|
|
|
'to)))
|
|
|
|
(if (listp to-field)
|
|
|
|
(car to-field)
|
|
|
|
to-field)))
|
2008-03-14 13:22:03 -04:00
|
|
|
(subject (let (wl-thr-indent-string wl-parent-message-entity)
|
|
|
|
(wl-summary-line-subject)))
|
|
|
|
desc link)
|
2008-03-20 05:53:29 -04:00
|
|
|
(org-store-link-props :type "wl" :from from :to to
|
2008-03-14 13:22:03 -04:00
|
|
|
:subject subject :message-id message-id)
|
2008-03-20 05:53:29 -04:00
|
|
|
(setq message-id (org-remove-angle-brackets message-id))
|
|
|
|
(setq desc (org-email-link-description))
|
|
|
|
(setq link (org-make-link "wl:" folder-name
|
2008-03-14 13:22:03 -04:00
|
|
|
"#" message-id))
|
2008-03-20 05:53:29 -04:00
|
|
|
(org-add-link-props :link link :description desc)
|
|
|
|
link)))
|
2008-03-14 13:22:03 -04:00
|
|
|
|
|
|
|
(defun org-wl-open (path)
|
2008-03-21 12:10:23 -04:00
|
|
|
"Follow the WL message link specified by PATH."
|
2008-03-22 11:52:18 -04:00
|
|
|
(require 'wl)
|
|
|
|
(unless wl-init (wl))
|
2008-03-20 05:53:29 -04:00
|
|
|
;; XXX: The imap-uw's MH folder names start with "%#".
|
|
|
|
(if (not (string-match "\\`\\(\\(?:%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path))
|
|
|
|
(error "Error in Wanderlust link"))
|
|
|
|
(let ((folder (match-string 1 path))
|
|
|
|
(article (match-string 3 path)))
|
2008-09-03 05:23:33 -04:00
|
|
|
(if (not (elmo-folder-exists-p (org-no-warnings
|
|
|
|
(wl-folder-get-elmo-folder folder))))
|
2008-03-20 05:53:29 -04:00
|
|
|
(error "No such folder: %s" folder))
|
|
|
|
(let ((old-buf (current-buffer))
|
|
|
|
(old-point (point-marker)))
|
|
|
|
(wl-folder-goto-folder-subr folder)
|
|
|
|
(save-excursion
|
|
|
|
;; XXX: `wl-folder-goto-folder-subr' moves point to the
|
|
|
|
;; beginning of the current line. So, restore the point
|
|
|
|
;; in the old buffer.
|
|
|
|
(set-buffer old-buf)
|
|
|
|
(goto-char old-point))
|
|
|
|
(and (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets
|
|
|
|
article))
|
|
|
|
(wl-summary-redisplay)))))
|
2008-03-14 13:22:03 -04:00
|
|
|
|
|
|
|
(provide 'org-wl)
|
|
|
|
|
2008-04-29 01:15:41 -04:00
|
|
|
;; arch-tag: 29b75a0f-ef2e-430b-8abc-acff75bde54a
|
|
|
|
|
2008-03-21 12:10:23 -04:00
|
|
|
;;; org-wl.el ends here
|