emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug: ol-notmuch.el: calls `notmuch-show' with arbitrary search query


From: Sean Whitton
Subject: Re: Bug: ol-notmuch.el: calls `notmuch-show' with arbitrary search query
Date: Tue, 26 Nov 2019 10:41:51 -0700

Dear maintainers,

On Thu 21 Nov 2019 at 02:37PM -07, Sean Whitton wrote:

> The function `org-notmuch-follow-link' in {org,ol}-notmuch.el calls
> `notmuch-show' with an arbitrary notmuch search query.  However, the
> docstring for `notmuch-show' specifies that a notmuch thread ID, rather
> than an arbitrary notmuch query, should be supplied to `notmuch-show'.
>
> The effect of this is that the variable `notmuch-show-thread-id' may
> contain an arbitrary search query rather than a thread ID.  That broke
> some code of mine which uses that variable.
>
> `org-notmuch-follow-link' needs to continue to accept an arbitrary query
> (as notmuch thread IDs are not stable), but it should convert it to a
> thread ID before passing it to `notmuch-show'.

Here is my workaround.  If this approach seems sensible I can prepare a
patch to `org-notmuch-follow-link` in ol-notmuch.el.

    (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]