+(defun notmuch-show-markup-this-header ()
+ (if (re-search-forward notmuch-show-header-begin-regexp nil t)
+ (progn
+ (overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
+ 'invisible 'notmuch-show-marker)
+ (next-line 1)
+ (beginning-of-line)
+ (let ((beg (point)))
+ (if (re-search-forward notmuch-show-header-end-regexp nil t)
+ (progn
+ (overlay-put (make-overlay beg (match-beginning 0))
+ 'invisible 'notmuch-show-header)
+ (overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
+ 'invisible 'notmuch-show-marker)))))
+ (goto-char (point-max))))
+
+(defun notmuch-show-markup-headers ()
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (notmuch-show-markup-this-header))))
+
+(defun notmuch-show-toggle-headers-visible ()
+ "Toggle visibility of header fields"
+ (interactive)
+ (if notmuch-show-headers-visible
+ (progn
+ (add-to-invisibility-spec 'notmuch-show-header)
+ (set 'notmuch-show-headers-visible nil)
+ ; Need to force the redisplay for some reason
+ (force-window-update)
+ (redisplay t))
+ (remove-from-invisibility-spec 'notmuch-show-header)
+ (set 'notmuch-show-headers-visible t)
+ (force-window-update)
+ (redisplay t)))
+