      "gR" #'notmuch-poll-and-refresh-this-buffer
      "gr" #'notmuch-refresh-this-buffer
      "H" #'notmuch-help
+     "J" #'pjones:notmuch-mark-read
      "M" #'pjones:notmuch-move-message
      "q" #'notmuch-bury-or-kill-this-buffer
      "s" #'notmuch-search

  "y T" #'notmuch-show-stash-tags
  "y t" #'notmuch-show-stash-to)

(defun pjones:notmuch-delete-thread (&optional undelete beg end)
  "Delete messages between BEG and END.

If UNDELETE is non-nil then reverse the delete operation."
  (interactive (cons current-prefix-arg (notmuch-interactive-region)))
  (let* ((tags '("+deleted" "-unread" "+move"))
         (query (notmuch-tag-change-list tags undelete)))
    (pcase major-mode
      ('notmuch-search-mode
       (notmuch-search-tag query)

      ('notmuch-show-mode
       (apply #'notmuch-show-tag-message query)
       (unless (notmuch-show-next-open-message) (notmuch-show-next-thread t))))))

(defun pjones:notmuch-delete-thread (&optional undelete beg end)
  "Delete messages between BEG and END.
If UNDELETE is non-nil then reverse the delete operation."
  (interactive (cons current-prefix-arg (notmuch-interactive-region)))
  (let ((tags '("+deleted" "-unread" "+move")))
    (pjones:notmuch-tag-thread tags undelete beg end)))

(defun pjones:notmuch-mark-read (&optional unread beg end)
  "Tag messages between BEG and END as read.
If UNREAD is non-nil, tag them as unread instead."
  (interactive (cons current-prefix-arg (notmuch-interactive-region)))
  (pjones:notmuch-tag-thread '("-unread") unread beg end))

(defun pjones:notmuch-mail-folders (&optional keep)
  "Return a list of valid folder names.
