org-contacts-wl.el 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ;;; org-contacts-wl.el --- Org-contacts support for Wanderlust
  2. ;; Copyright (C) 2011 Michael Markert <markert.michael@googlemail.com>
  3. ;; Author: Michael Markert <markert.michael@googlemail.com>
  4. ;;
  5. ;; This file is NOT part of GNU Emacs.
  6. ;;
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18. ;;
  19. ;;; Code:
  20. (require 'std11)
  21. (require 'elmo)
  22. (require 'wl-address)
  23. (require 'wl-summary)
  24. (defun wl-get-from-header-content ()
  25. (save-excursion
  26. (set-buffer (org-capture-get :original-buffer))
  27. (cond
  28. ((eq major-mode 'wl-summary-mode) (when wl-summary-buffer-elmo-folder
  29. (elmo-message-field
  30. wl-summary-buffer-elmo-folder
  31. (wl-summary-message-number)
  32. 'from)))
  33. ((eq major-mode 'mime-view-mode) (std11-narrow-to-header)
  34. (prog1
  35. (std11-fetch-field "From")
  36. (widen))))))
  37. (defun org-contacts-template-wl-name (&optional return-value)
  38. (let ((from (wl-get-from-header-content)))
  39. (or (and from (wl-address-header-extract-realname from))
  40. return-value
  41. "%^{Name}")))
  42. (defun org-contacts-template-wl-email (&optional return-value)
  43. (let ((from (wl-get-from-header-content)))
  44. (or (and from (wl-address-header-extract-address from))
  45. return-value
  46. (concat "%^{" org-contacts-email-property "}p"))))
  47. (provide 'org-contacts-wl)