bug: notmuch-poll doesn't check return value

Ketil Malde ketil at malde.org
Mon Sep 14 05:18:14 PDT 2015


Hi,

I've been stumped occasionally when new mail fails to appear in notmuch,
and then I suddenly discover it by some other means (web front end,
mobile, etc).

The problem is that notmuch-poll fails silently when it fails, which is
usually due to broken symlinks in my mail directories, or some IMAP
configuration mistake.  Easy to fix when you know about it.

I've, uh, "fixed" this by redefining notmuch-poll like so:

---8<-------------------------------------
;;; Make notmuch-poll fail gracelessly when something goes wrong
;;; Better than failing silently, in ancy case.
(defun notmuch-poll ()
  "Run \"notmuch new\" or an external script to import mail.

Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
depending on the value of `notmuch-poll-script'."
  (interactive)
  (if (not (equal 0
		  (if (stringp notmuch-poll-script)
		      (unless (string= notmuch-poll-script "")
			(call-process notmuch-poll-script nil nil))
		    (call-process notmuch-command nil nil nil "new"))))
     (error "Notmuch: poll failed!")))
---8<-------------------------------------

Surely, somebody who knows lisp can do something far more elegant than
this, but the point is to bug out when something doesn't work.

In addtion, I had to fix my notmuch-poll-script, which contains
'offlineimap', then 'notmuch new', followed by some tagging commands.
As the tagging commands tend to work even if 'new' doesn't, this will
often (pretend to) exit successfully.  A 'set -e' at the top of the
script is probably a good idea, and should probably be mentioned in
documentation somewhere.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the notmuch mailing list