From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthieu Lemerre Subject: Org support for the notmuch mail client Date: Sun, 28 Nov 2010 17:26:29 +0100 Message-ID: <87k4jx4doq.fsf@free.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=43747 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMjso-0006iF-N9 for emacs-orgmode@gnu.org; Sun, 28 Nov 2010 11:13:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PMjsn-0002gm-Hj for emacs-orgmode@gnu.org; Sun, 28 Nov 2010 11:13:46 -0500 Received: from smtp3-g21.free.fr ([212.27.42.3]:45512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PMjsm-0002fv-VW for emacs-orgmode@gnu.org; Sun, 28 Nov 2010 11:13:45 -0500 Received: from racin (unknown [82.239.207.166]) by smtp3-g21.free.fr (Postfix) with ESMTP id AEEE9A627A for ; Sun, 28 Nov 2010 17:13:39 +0100 (CET) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Hello, org-mode! The attached file implements links to mail collections and "searchs" to the notmuch mail client. A "search" is a query to be performed by notmuch; it is the equivalent to folders in other mail clients. Similarly, mails are refered to by a query, so both a link can refer to several mails. I had read on this list (http://www.mail-archive.com/emacs-orgmode@gnu.org/msg28411.html) that there already was an implementation of links to notmuch, but it could not be implemented because of paperwork problems. I have implemented this because I got tired of waiting :) I'm new to hacking org-mode, and the implementation might not be perfect. I would be happy to receive comments. I already have one question: why is it needed to url-encode the links in org mode? For instance, I would like to be able to hand-write links like this: [[notmuch-search:to:xxx and not from:yyyy]] But it only works if I org-link-encode/org-link-decode the link (else, the and not .. is completely skipped from the query). Similarly, if I do (org-open-link-from-string "notmuch:id:\"7f39qo4aut.fsf@aeuaue.free.fr\"")) The last " gets removed in the argument I receive in org-notmuch-open. This is a pity because hand-writing url-encoded links is not user-friendly. PS: could you please Cc me because I am not subscribed to the list. Matthieu --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-notmuch.el Content-Transfer-Encoding: quoted-printable ;;; org-notmuch.el --- Support for links to notmuch messages from within Or= g-mode ;; Copyright (C) 2010 Matthieu Lemerre ;; Author: Matthieu Lemerre ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org ;; This file 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 file 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 GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; This file implements links to notmuch messages and "searchs". A ;; search is a query to be performed by notmuch; it is the equivalent ;; to folders in other mail clients. Similarly, mails are refered to ;; by a query, so both a link can refer to several mails. ;; Links have one the following form ;; notmuch: ;; notmuch-search:.=20 ;; The first form open the queries in notmuch-show mode, whereas the ;; second link open it in notmuch-search mode. Note that queries are ;; performed at the time the link is opened, and the result may be ;; different from whet the link was stored. ;;; Code: ;; Install the link type (org-add-link-type "notmuch" 'org-notmuch-open) (add-hook 'org-store-link-functions 'org-notmuch-store-link) (defun org-notmuch-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-show-mode) (let* ((message-id (notmuch-show-get-prop :id)) (subject (notmuch-show-get-subject)) (to (notmuch-show-get-to)) (from (notmuch-show-get-from)) desc link) (org-store-link-props :type "notmuch" :from from :to to :subject subject :message-id message-id) (setq desc (org-email-link-description)) (setq link (org-make-link "notmuch:" "id:" message-id)) (org-add-link-props :link link :description desc) link))) =20=20 (defun org-notmuch-open (path) "Follow a notmuch message link specified by PATH." (org-notmuch-follow-link path)) (defun org-notmuch-follow-link (search) "Follow a notmuch link to SEARCH.=20 Can link to more than one message, if so all matching messages are shown." (require 'notmuch) (notmuch-show (org-link-unescape search))) (org-add-link-type "notmuch-search" 'org-notmuch-search-open) (add-hook 'org-store-link-functions 'org-notmuch-search-store-link) (defun org-notmuch-search-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-search-mode) (let ((link (org-make-link "notmuch-search:"=20 (org-link-escape notmuch-search-query-string))) (desc (concat "Notmuch search: " notmuch-search-query-string))) (org-store-link-props :type "notmuch-search"=20 :link link :description desc) link))) (defun org-notmuch-search-open (path) "Follow a notmuch message link specified by PATH." (message path) (org-notmuch-search-follow-link path)) (defun org-notmuch-search-follow-link (search) "Follow a notmuch link by displaying SEARCH in notmuch-search mode." (require 'notmuch) (notmuch-search (org-link-unescape search))) (provide 'org-notmuch) ;;; org-notmuch.el ends here --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--