diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/doc/jao-recoll.el | 9 | ||||
-rw-r--r-- | lib/net/jao-maildir.el | 28 | ||||
-rw-r--r-- | lib/org/jao-org-links.el | 12 |
3 files changed, 47 insertions, 2 deletions
diff --git a/lib/doc/jao-recoll.el b/lib/doc/jao-recoll.el index be77100..7c64c7d 100644 --- a/lib/doc/jao-recoll.el +++ b/lib/doc/jao-recoll.el @@ -57,8 +57,13 @@ buffer using org mode." (forward-line 1)) (open-line 1) (while (search-forward-regexp jao-recoll--file-regexp nil t) - (setq lnk (concat "doc:" (file-name-nondirectory (match-string 2)))) - (replace-match "* [[\\2][\\3]] (\\1)") + (setq lnk + (cond ((string= (match-string 1) "application/pdf") + (concat "doc:" (file-name-nondirectory (match-string 2)))) + ((string= (match-string 1) "message/rfc822") + (concat "message:" (substring (match-string 2) 7))) + (t (match-string 2)))) + (replace-match (format "* [[%s][\\3]] (\\1)" lnk)) (forward-line) (let ((kill-whole-line t)) (kill-line)) (while (and (not (eobp)) (not (looking-at-p "/SNIPPETS"))) diff --git a/lib/net/jao-maildir.el b/lib/net/jao-maildir.el index d68fbe0..d7cd4d6 100644 --- a/lib/net/jao-maildir.el +++ b/lib/net/jao-maildir.el @@ -34,6 +34,7 @@ (defvar jao-maildir-echo-p t) (defvar jao-maildir-tracked-maildirs nil) (defvar jao-maildir-info-string "") +(defvar jao-maildir-home (expand-file-name "~/var/mail")) (defgroup jao-maildir-faces nil "Faces" :group 'faces) @@ -150,6 +151,33 @@ (t (error "Invalid mode-line value"))) (jao-maildir--setup-watches cb)) +;;;###autoload +(defun jao-maildir-file-to-group (file) + "Calculate the Gnus group name from the given file name. +Example: + + IN: /home/jao/var/mail/jao/foo/cur/1259184569.M4818P3384.localhost,W=6921:2,S + OUT: nnimap:jao/foo + + IN: /home/jao/var/mail/gmane/foo/bar/100 + OUT: nntp+localhost:gmane.foo.bar + + IN: /home/jao/var/mail/bigml/cur/1259176906.M17483P24679.localhost,W=2488:2,S + OUT:nnimap:bigml/inbox" + (let* ((g (directory-file-name (file-name-directory file))) + (g (replace-regexp-in-string (file-name-as-directory jao-maildir-home) + "" g)) + (nntp (string-match-p "^\\(gmane\\|gwene\\)/" g)) + (g (if nntp + (concat "nntp+localhost:" g) + (replace-regexp-in-string "^\\([^/]+\\)/" "nnimap:\\1/" + (file-name-directory g) t))) + (g (if nntp (replace-regexp-in-string "/" "." g) g)) + (g (replace-regexp-in-string "[/.]$" "" g))) + (cond ((string-match ":$" g) (concat g "inbox")) + (nntp g) + (t (replace-regexp-in-string ":\\." ":" g))))) + (provide 'jao-maildir) ;;; jao-maildir.el ends here diff --git a/lib/org/jao-org-links.el b/lib/org/jao-org-links.el index 21bf27c..f8080f5 100644 --- a/lib/org/jao-org-links.el +++ b/lib/org/jao-org-links.el @@ -1,4 +1,5 @@ (require 'jao-org-utils) +(require 'jao-maildir) (require 'pdf-info) (defvar jao-org--sink-dir "./") @@ -77,6 +78,16 @@ (setq outline (cdr outline))) (replace-regexp-in-string "[[:blank:]]+" " " cur-title))) +(defun jao-org-links-open-mail (fname) + (let ((group (jao-maildir-file-to-group fname)) + (id (with-temp-buffer + (insert-file fname) + (goto-char (point-min)) + (message-mode) + (not-modified) + (message-fetch-field "Message-ID")))) + (when (and group id) (org-gnus-follow-link group id)))) + ;;;###autoload (defvar jao-org-links-pdf-store-fun nil) @@ -107,6 +118,7 @@ :follow #'jao-org-links--follow-doc :complete #'jao-org-links--complete-doc :store #'jao-org-links--store-pdf-link) + (org-link-set-parameters "message" :follow #'jao-org-links-open-mail) (setq jao-org--sink-dir (file-name-as-directory sink-dir))) ;;;###autoload |