unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ketil Malde <ketil@malde.org>
To: notmuch@notmuchmail.org
Subject: bug: notmuch-poll doesn't check return value
Date: Mon, 14 Sep 2015 14:18:14 +0200	[thread overview]
Message-ID: <87bnd5qjnd.fsf@wespe.malde.org> (raw)


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

             reply	other threads:[~2015-09-14 12:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 12:18 Ketil Malde [this message]
2015-10-28 18:28 ` [PATCH] emacs: poll: return useful errors when poll fails Mark Walters
2015-10-28 20:18   ` Tomi Ollila
2015-11-23 12:51   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bnd5qjnd.fsf@wespe.malde.org \
    --to=ketil@malde.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).