[BUG] [notmuch-tree] Display problems when database is locked

Simon Castellan simon_notmuch at phis.me
Sat Jan 2 14:33:35 PST 2016


Hi,

I'm using notmuch-tree and I encountered a slightly annoying bug. When
browsing through a notmuch-tree buffer, if I open up a message whose
tags needs to be changed (eg. the message needs to be marked read), then
on the /next/ message, the bottom part of the pane does not get killed
and thus, the top part (which is tiny) of the pane gets split again.

How to reproduce [I'm using notmuch-0.21 and emacs 24.4.1 from debian]
----------------

1. Mark some messages to be unread and then run (notmuch-tree
"is:unread")

2. Make sure your notmuch database is locked (for that purpose I run a
   `while true; do notmuch new; done` in a side terminal)

3. Open the first unread message, then press "n" to go the next one.
   At this point, the screen should be split in three instead of two.

How to fix it
-------------

This is due to notmuch-show not returning when the database is locked
and the message cannot be marked read. This results in the end of
notmuch-tree-show-message-in not being executed and some variable
(namely notmuch-tree-message-buffer) having wrong values.

I am not sure what is the best way to fix it, but what I'm using at a
hack is to wrap around the call to notmuch-show in a
`with-demoted-errors` so that the execution can continue in case of
failure, and close the bottom part in case of a failure. Hence when this
happens, the bottom part disappears which is better than messing up the
window configuration. This is what it looks like:

    (defun notmuch-tree-show-message-in ()
      "Show the current message (in split-pane)."
      (interactive)
      (let ((id (notmuch-tree-get-message-id))
    	(inhibit-read-only t)
    	buffer)
        (when id
          ;; We close and reopen the window to kill off un-needed buffers
          ;; this might cause flickering but seems ok.
          (notmuch-tree-close-message-window)
          (setq notmuch-tree-message-window
    	    (split-window-vertically (/ (window-height) 4)))
          (with-selected-window notmuch-tree-message-window
    	;; Since we are only displaying one message do not indent.
    	(let ((notmuch-show-indent-messages-width 0)
    	      (notmuch-show-only-matching-messages t))
    	  (setq buffer (with-demoted-errors (notmuch-show id)))))
          (unless buffer
            (delete-window notmuch-tree-message-window))
          (when buffer
            ;; We need the `let' as notmuch-tree-message-window is buffer local.
            (let ((window notmuch-tree-message-window))
              (with-current-buffer buffer
                (setq notmuch-tree-message-window window)
                (add-hook 'kill-buffer-hook 'notmuch-tree-message-window-kill-hook)))
            (setq notmuch-tree-message-buffer buffer)
            (when notmuch-show-mark-read-tags
              (notmuch-tree-tag-update-display notmuch-show-mark-read-tags))
            ))))
    

Cheers,

Simon.


More information about the notmuch mailing list