]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-show.el
Simplify message and headers visibility code in notmuch-show view.
[notmuch] / emacs / notmuch-show.el
index fb91c83856eb5e248d7bd64ab7a9522593822550..0d9b52a7f1b29769cffee30e1dbef50e7b0edab5 100644 (file)
@@ -546,7 +546,7 @@ current buffer, if possible."
     (save-excursion
       (save-restriction
        (narrow-to-region start (point-max))
-       (run-hook-with-args 'notmuch-show-insert-text/plain-hook depth))))
+       (run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))
   t)
 
 (defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)
@@ -713,6 +713,9 @@ current buffer, if possible."
 
     (setq content-start (point-marker))
 
+    (plist-put msg :headers-invis-spec headers-invis-spec)
+    (plist-put msg :message-invis-spec message-invis-spec)
+
     ;; Set `headers-start' to point after the 'Subject:' header to be
     ;; compatible with the existing implementation. This just sets it
     ;; to after the first header.
@@ -750,10 +753,10 @@ current buffer, if possible."
     ;; message.
     (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
 
-    (plist-put msg :headers-invis-spec headers-invis-spec)
-    (overlay-put (make-overlay headers-start headers-end) 'invisible headers-invis-spec)
-
-    (plist-put msg :message-invis-spec message-invis-spec)
+    (let ((headers-overlay (make-overlay headers-start headers-end))
+          (invis-specs (list headers-invis-spec message-invis-spec)))
+      (overlay-put headers-overlay 'invisible invis-specs)
+      (overlay-put headers-overlay 'priority 10))
     (overlay-put (make-overlay body-start body-end) 'invisible message-invis-spec)
 
     ;; Save the properties for this message. Currently this saves the
@@ -992,20 +995,11 @@ All currently available key bindings:
       (add-to-invisibility-spec spec))))
 
 (defun notmuch-show-message-visible (props visible-p)
-  (if visible-p
-      ;; When making the message visible, the headers may or not be
-      ;; visible. So we check that property separately.
-      (let ((headers-visible (plist-get props :headers-visible)))
-       (notmuch-show-element-visible props headers-visible :headers-invis-spec)
-       (notmuch-show-element-visible props t :message-invis-spec))
-    (notmuch-show-element-visible props nil :headers-invis-spec)
-    (notmuch-show-element-visible props nil :message-invis-spec))
-
+  (notmuch-show-element-visible props visible-p :message-invis-spec)
   (notmuch-show-set-prop :message-visible visible-p props))
 
 (defun notmuch-show-headers-visible (props visible-p)
-  (if (plist-get props :message-visible)
-      (notmuch-show-element-visible props visible-p :headers-invis-spec))
+  (notmuch-show-element-visible props visible-p :headers-invis-spec)
   (notmuch-show-set-prop :headers-visible visible-p props))
 
 ;; Functions for setting and getting attributes of the current