From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Georg C. F. Greve" Subject: Re: Integration of Org mode with Mairix: org-mairix.el Date: Thu, 27 Sep 2007 00:30:30 +0200 Message-ID: References: <87wsudv5tp.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0735162452==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IafXB-0008KE-8d for emacs-orgmode@gnu.org; Wed, 26 Sep 2007 18:39:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IafXA-0008Jh-Of for emacs-orgmode@gnu.org; Wed, 26 Sep 2007 18:39:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IafXA-0008JF-B1 for emacs-orgmode@gnu.org; Wed, 26 Sep 2007 18:39:08 -0400 Received: from gadolin.fsfeurope.org ([195.176.254.152]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IafX9-0001tU-IB for emacs-orgmode@gnu.org; Wed, 26 Sep 2007 18:39:08 -0400 In-Reply-To: <87wsudv5tp.fsf@bzg.ath.cx> (Bastien's message of "Wed, 26 Sep 2007 16:50:42 +0200") 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: Bastien Cc: emacs-orgmode@gnu.org --===============0735162452== Content-Type: multipart/signed; boundary="20070927003030+02008953963025769690-247300065"; micalg=pgp-sha1; protocol="application/pgp-signature" --20070927003030+02008953963025769690-247300065 Content-Type: multipart/mixed; boundary="20070927003030+02001300312435623283212493948" --20070927003030+02001300312435623283212493948 Content-Transfer-Encoding: quoted-printable On Wed, 26 Sep 2007 16:50:42 +0200 Bastien wrote:=20 b> Please have a look at the patch below and tell me if it solves the b> issue above. Look for the small FIXME: (bzg) cookies in the patch. Thanks a lot for your help. The zombie issue is still present, and I've tried to address the FIXME: issues as well as possible, or ask for clarification on the point. b> BTW, this might be just personal taste, but I would prefer a shorter b> syntax for thread searches (like mairix:t). Right now " --thread" b> in the link is converted as "%20--thread" and this is not parsed by b> the (split-string ... " ") part of your code. Strange, it worked when I first tested it, and now does no more. I agree shorter is nicer, so changed the syntax accordingly. Version 0.2 attached below. Please test, comment, improve... Best rgeards, Georg --20070927003030+02001300312435623283212493948 Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-mairix.el Content-Transfer-Encoding: quoted-printable ;;; org-mairix.el - Support for hooking mairix search into Org for differen= t MUAs ;; ;; Copyright (C) 2007 Georg C. F. Greve ;; ;; Author: Georg C. F. Greve ;; Keywords: outlines, hypermedia, calendar, wp, email, mairix ;; Purpose: Integrate mairix email searching into Org mode ;; See http://orgmode.org and http://www.rpcurnow.force9.co.uk/mairix/ ;; Version: 0.2 ;; ;; 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 3, or (at your option) ;; any later version. ;; It 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. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;; (require 'org) ;;; The custom variables (defgroup org-mairix nil "Mairix support/integration in org." :tag "Org Mairix" :group 'org) (defcustom org-mairix-threaded-links t "Should new links be created as threaded links? If t, links will be stored as threaded searches. If nil, links will be stored as non-threaded searches." :group 'org-mairix :type 'boolean) (defcustom org-mairix-augmented-links nil "Should new links be created as augmenting searches? If t, links will be stored as augmenting searches. If nil, links will be stored as normal searches. Attention: When activating this option, you will need to remove old articles from your mairix results group in some other way, mairix will not do it for you." :group 'org-mairix :type 'boolean) (defcustom org-mairix-display-hook 'org-mairix-gnus-display-results "Hook to call to display the results of a successful mairix search. Defaults to Gnus, feel free to add your own MUAs or methods." :group 'org-mairix :type 'hook) (defcustom org-mairix-executable "mairix" "The mairix executable to call. If your paths are set up correctly, you should not need to change this." :group 'org-mairix :type 'string) (defgroup org-mairix-gnus nil "Use gnus for mairix support in org." :tag "Org Mairix Gnus" :group 'org-mairix) (defcustom org-mairix-gnus-results-group "nnmaildir:mairix" "The group that is configured to hold the mairix search results, which needs to be setup independently of the org-mairix integration, along with general mairix configuration." :group 'org-mairix-gnus :type 'string) ;;; The hooks to integrate mairix into org (org-add-link-type "mairix" 'org-mairix-open) (add-hook 'org-store-link-functions 'org-mairix-store-link) ;;; Generic org-mairix functions (defun org-mairix-store-link () "Store a link to the current message as a Mairix search for its Message ID." ;; gnus integration (when (memq major-mode '(gnus-summary-mode gnus-article-mode)) (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary)) (let* ((article (gnus-summary-article-number)) (header (gnus-summary-article-header article)) (from (mail-header-from header)) (message-id (mail-header-id header)) ;; FIXME: (bzg) we don't need the date ;; (gg) really? but what if people were to use that in their "org-email= -link-description" customisation? (date (mail-header-date header)) (subject (gnus-summary-subject-string))) (org-store-link-props :type "mairix" :from from :subject subject :message-id message-id) (setq cpltxt (org-email-link-description)) (org-store-link-props :link (concat "mairix:" (if org-mairix-threaded-links "t:") (if org-mairix-augmented-links "a:") message-id) :description cpltxt)))) (defun org-mairix-open (path) "Function to open mairix link. We first need to split it into its individual parts, and then extract the message-id to be passed on to the display function before call mairix, evaluate the number of matches returned, and make sure to only call display of mairix succeeded in matching." ;; FIXME (bzg) mhh... better use let* construct for arguments, ;; message-id and cmdline. ;; (gg) tried to do it as best as possible with new parsing, feel free to= improve (let* ((cmdline org-mairix-executable)) (if (string< "t:" path) (progn (setq path (substring path 2 nil)) (setq cmdline (concat cmdline " --threads")))) (if (string< "a:" path) (progn (setq path (substring path 2 nil)) (setq cmdline (concat cmdline " --augment")))) (let* ((message-id (org-remove-angle-brackets path))) (setq cmdline (concat cmdline " m:" message-id)) (print cmdline) (setq retval (shell-command-to-string (concat cmdline " m:" message-id))) (string-match "\[0-9\]+" retval) (setq matches (string-to-number (match-string 0 retval))) (if (eq matches 0) (message "Link failed: no matches, sorry.") (message "Link returned %d matches." matches) (run-hook-with-args 'org-mairix-display-hook message-id))))) ;;; Functions necessary for gnus integration (defun org-mairix-gnus-display-results (message-id) "Display results of mairix search in Gnus. Note: This does not work as cleanly as I would like it to. The problem being that Gnus should simply reread the group cleanly, without remembering anything. At the moment it seems to be unable to do that -- so you're likely to see zombies floating around. Gnus developers couldn't really help, see: http://article.gmane.org/gmane.emacs.gnus.general/65248 If you can improve this, please do!" (require 'gnus) (require 'gnus-sum) ;;FIXME (bzg) we need to call Gnus first, don't we? ;;(gg) that checks for new news, AFAIK, slowing things down quite a bit i= s there an "assert" function? (funcall (cdr (assq 'gnus org-link-frame-setup))) (gnus-group-quick-select-group 0 org-mairix-gnus-results-group) (gnus-summary-reselect-current-group t t) (gnus-summary-select-article nil t t (car (gnus-find-matching-articles "message-id" message-id)))) (provide 'org-mairix) ;;; org-mairix.el ends here --20070927003030+02001300312435623283212493948 Content-Transfer-Encoding: quoted-printable =2D-=20 Georg C. F. Greve Free Software Foundation Europe (http://fsfeurope.org) Join the Fellowship and protect your freedom! (http://www.fsfe.org) What everyone should know about DRM (http://DRM.info) --20070927003030+02001300312435623283212493948-- --20070927003030+02008953963025769690-247300065 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQCVAwUBRvrdhik9sUy32wQcAQLyJwQAk97FGsost4QGLyeCdOsCpWDd7UQdZ6Ea jOpBPbW43NwR4iUkCVY6J8rR1JwaApQR5BxgftBGa6kuvv1FuwskrZgSKS8XfeBp ujZc918PT9sfuD1v3LJLkYAHI6nmW3zXRAOzjE5s6dqPI8njykuFv5VO0i66kQGI evwuac4HJ2c= =mqy1 -----END PGP SIGNATURE----- --20070927003030+02008953963025769690-247300065-- --===============0735162452== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0735162452==--