123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- (require 'org)
- (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)
- (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)
- (declare-function elmo-msgdb-overview-get-entity "ext:elmo" (id msgdb) t)
- (declare-function wl "ext:wl" () t)
- (declare-function wl-summary-buffer-msgdb "ext:wl-folder" () t)
- (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))
- (declare-function wl-summary-registered-temp-mark "ext:wl-action" (number))
- (declare-function wl-folder-goto-folder-subr "ext:wl-folder"
- (&optional folder sticky))
- (defvar wl-init)
- (defvar wl-summary-buffer-elmo-folder)
- (defvar wl-summary-buffer-folder-name)
- (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* ((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"))
- (nth 2 mark-info)
- wl-summary-buffer-folder-name))
- (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 (let ((from-field (elmo-message-entity-field wl-message-entity
- 'from)))
- (if (listp from-field)
- (car from-field)
- from-field)))
- (to (let ((to-field (elmo-message-entity-field wl-message-entity
- 'to)))
- (if (listp to-field)
- (car to-field)
- to-field)))
- (subject (let (wl-thr-indent-string wl-parent-message-entity)
- (wl-summary-line-subject)))
- desc link)
-
-
- (set-text-properties 0 (length subject) nil subject)
- (org-store-link-props :type "wl" :from from :to to
- :subject subject :message-id message-id)
- (setq message-id (org-remove-angle-brackets message-id))
- (setq desc (org-email-link-description))
- (setq link (org-make-link "wl:" folder-name
- "#" message-id))
- (org-add-link-props :link link :description desc)
- link)))
- (defun org-wl-open (path)
- "Follow the WL message link specified by PATH."
- (require 'wl)
- (unless wl-init (wl))
-
- (if (not (string-match "\\`\\(\\(?:%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path))
- (error "Error in Wanderlust link"))
- (let ((folder (match-string 1 path))
- (article (match-string 3 path)))
- (if (not (elmo-folder-exists-p (org-no-warnings
- (wl-folder-get-elmo-folder folder))))
- (error "No such folder: %s" folder))
- (let ((old-buf (current-buffer))
- (old-point (point-marker)))
- (wl-folder-goto-folder-subr folder)
- (save-excursion
-
-
-
- (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)))))
- (provide 'org-wl)
|