From mboxrd@z Thu Jan 1 00:00:00 1970 From: racin@free.fr Subject: Re: Bug: ol-notmuch.el: calls `notmuch-show' with arbitrary search query Date: Tue, 26 Nov 2019 20:17:27 +0100 (CET) Message-ID: <1630223474.433436589.1574795847430.JavaMail.zimbra@free.fr> References: <87h82wrjvb.fsf@iris.silentflame.com> <87y2w21qn4.fsf@iris.silentflame.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:34178) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZgLE-0000xA-4l for emacs-orgmode@gnu.org; Tue, 26 Nov 2019 14:17:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZgLB-0004iG-MM for emacs-orgmode@gnu.org; Tue, 26 Nov 2019 14:17:39 -0500 Received: from smtp3-g21.free.fr ([212.27.42.3]:19019) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZgL9-0004Zl-Hu for emacs-orgmode@gnu.org; Tue, 26 Nov 2019 14:17:35 -0500 In-Reply-To: <87y2w21qn4.fsf@iris.silentflame.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Sean Whitton Cc: notmuch , emacs-orgmode Hi, > > Here is my workaround. If this approach seems sensible I can prepare a > patch to `org-notmuch-follow-link` in ol-notmuch.el. Your approach probably works most of the time, but I don't like the idea of having to perform 2 queries when one should be enough. I think a better approach would be to change notmuch-show (or add a new version) that would allow taking arbitrary queries (and especially, message ids) as input. This probably used to be the case. Note that the command line notmuch show function does accept arbitrary search terms as an argument I think updating notmuch-show to compute the thread id from the query (instead of assuming that the input is a thread id) would be the best way to go, but you should see that with the notmuch developers. Best regards Matthieu Lemerre > > (use-package org-notmuch > :init > ;; the default value for `org-notmuch-open-function' is > ;; `org-notmuch-follow-link', but that function is broken: it calls > ;; `notmuch-show' with a search query rather than a thread ID. This > ;; causes `notmuch-show-thread-id' to be populated with a value > ;; which is not a thread ID, which breaks various other things > ;; > ;; so use a custom function instead > (defun spw--org-notmuch-follow-link (search) > (let ((thread-id > (substring > (shell-command-to-string > (combine-and-quote-strings (list "notmuch" "search" > "--output=threads" "--limit=1" > "--format=text" > "--format-version=4" search))) > 0 -1))) > (notmuch-show thread-id nil nil search search))) > (setq org-notmuch-open-function 'spw--org-notmuch-follow-link)) > > -- > Sean Whitton