]> git.cworth.org Git - notmuch-old/blobdiff - emacs/notmuch-show.el
emacs/show: provide a more friendly function to get duplicate num
[notmuch-old] / emacs / notmuch-show.el
index 05524c2eec0a372db4b3097a14488d9428c69516..e9a9ac2cc08c6e00dd7a0e18fa8a1f61430c071a 100644 (file)
@@ -555,7 +555,7 @@ message at DEPTH in the current thread."
      (if (> file-count 1)
         (let ((txt (format "%d/%d\n" duplicate file-count)))
           (concat
-           (notmuch-show-spaces-n (- (window-width) (+ (current-column) (length txt))))
+           (notmuch-show-spaces-n (max 0 (- (window-width) (+ (current-column) (length txt)))))
            txt))
        "\n"))
     (overlay-put (make-overlay start (point))
@@ -1811,10 +1811,10 @@ current thread."
 
 ;; dme: Would it make sense to use a macro for many of these?
 
-;; XXX TODO figure out what to do about multiple filenames
 (defun notmuch-show-get-filename ()
   "Return the filename of the current message."
-  (car (notmuch-show-get-prop :filename)))
+  (let ((duplicate (notmuch-show-get-duplicate)))
+    (nth (1- duplicate) (notmuch-show-get-prop :filename))))
 
 (defun notmuch-show-get-header (header &optional props)
   "Return the named header of the current message, if any."
@@ -1826,6 +1826,10 @@ current thread."
 (defun notmuch-show-get-date ()
   (notmuch-show-get-header :Date))
 
+(defun notmuch-show-get-duplicate ()
+  ;; if no duplicate property exists, assume first file
+  (or (notmuch-show-get-prop :duplicate) 1))
+
 (defun notmuch-show-get-timestamp ()
   (notmuch-show-get-prop :timestamp))
 
@@ -2020,13 +2024,15 @@ any effects from previous calls to
 (defun notmuch-show-reply (&optional prompt-for-sender)
   "Reply to the sender and all recipients of the current message."
   (interactive "P")
-  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender t))
+  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender t
+                        (notmuch-show-get-prop :duplicate)))
 
 (put 'notmuch-show-reply-sender 'notmuch-prefix-doc "... and prompt for sender")
 (defun notmuch-show-reply-sender (&optional prompt-for-sender)
   "Reply to the sender of the current message."
   (interactive "P")
-  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender nil))
+  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender nil
+                        (notmuch-show-get-prop :duplicate)))
 
 (put 'notmuch-show-forward-message 'notmuch-prefix-doc
      "... and prompt for sender")