(define-key map (kbd "C-p") 'notmuch-show-previous-line)
(define-key map "q" 'kill-this-buffer)
(define-key map "s" 'notmuch-show-toggle-signatures-visible)
+ (define-key map "w" 'notmuch-show-view-raw-message)
(define-key map "x" 'kill-this-buffer)
(define-key map "+" 'notmuch-show-add-tag)
(define-key map "-" 'notmuch-show-remove-tag)
"Keymap for \"notmuch show\" buffers.")
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
-(defvar notmuch-show-message-begin-regexp "\fmessage{")
-(defvar notmuch-show-message-end-regexp "\fmessage}")
-(defvar notmuch-show-header-begin-regexp "\fheader{")
-(defvar notmuch-show-header-end-regexp "\fheader}")
-(defvar notmuch-show-body-begin-regexp "\fbody{")
-(defvar notmuch-show-body-end-regexp "\fbody}")
-(defvar notmuch-show-attachment-begin-regexp "\fattachment{")
-(defvar notmuch-show-attachment-end-regexp "\fattachment}")
-(defvar notmuch-show-part-begin-regexp "\fpart{")
-(defvar notmuch-show-part-end-regexp "\fpart}")
-(defvar notmuch-show-marker-regexp "\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$")
-
-(defvar notmuch-show-id-regexp "ID: \\(.*\\)$")
-(defvar notmuch-show-tags-regexp "(\\([^)]*\\))$")
+(defvar notmuch-show-signature-lines-max 6
+ "Maximum length of signature that will be hidden by default.")
+
+(set 'notmuch-show-message-begin-regexp "\fmessage{")
+(set 'notmuch-show-message-end-regexp "\fmessage}")
+(set 'notmuch-show-header-begin-regexp "\fheader{")
+(set 'notmuch-show-header-end-regexp "\fheader}")
+(set 'notmuch-show-body-begin-regexp "\fbody{")
+(set 'notmuch-show-body-end-regexp "\fbody}")
+(set 'notmuch-show-attachment-begin-regexp "\fattachment{")
+(set 'notmuch-show-attachment-end-regexp "\fattachment}")
+(set 'notmuch-show-part-begin-regexp "\fpart{")
+(set 'notmuch-show-part-end-regexp "\fpart}")
+(set 'notmuch-show-marker-regexp "\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$")
+
+(set 'notmuch-show-id-regexp "ID: \\([^ ]*\\)")
+(set 'notmuch-show-filename-regexp "Filename: \\(.*\\)$")
+(set 'notmuch-show-tags-regexp "(\\([^)]*\\))$")
; XXX: This should be a generic function in emacs somewhere, not here
(defun point-invisible-p ()
(re-search-forward notmuch-show-id-regexp)
(buffer-substring (match-beginning 1) (match-end 1))))
+(defun notmuch-show-get-filename ()
+ (save-excursion
+ (beginning-of-line)
+ (if (not (looking-at notmuch-show-message-begin-regexp))
+ (re-search-backward notmuch-show-message-begin-regexp))
+ (re-search-forward notmuch-show-filename-regexp)
+ (buffer-substring (match-beginning 1) (match-end 1))))
+
(defun notmuch-show-set-tags (tags)
(save-excursion
(beginning-of-line)
(switch-to-buffer parent-buffer)
(notmuch-search-show-thread)))))
+(defun notmuch-show-view-raw-message ()
+ "View the raw email of the current message."
+ (interactive)
+ (view-file (notmuch-show-get-filename)))
+
(defun notmuch-show-move-to-current-message-summary-line ()
"Move to the beginning of the one-line summary of the current message.
(if (looking-at ">")
(progn
(while (looking-at ">")
- (next-line))
+ (forward-line))
(let ((overlay (make-overlay beg-sub (point))))
(overlay-put overlay 'invisible 'notmuch-show-citation)
(overlay-put overlay 'before-string
(concat "[" (number-to-string (count-lines beg-sub (point)))
- " quoted lines.]")))))
+ " quoted lines.]\n")))))
(if (looking-at "--[ ]?$")
- (let ((overlay (make-overlay beg-sub end)))
- (overlay-put overlay 'invisible 'notmuch-show-signature)
- (overlay-put overlay 'before-string
- (concat "[" (number-to-string (count-lines beg-sub (point)))
- "-line signature.]"))
- (goto-char end)))
- (next-line))))
+ (let ((sig-lines (count-lines beg-sub end)))
+ (if (<= sig-lines notmuch-show-signature-lines-max)
+ (progn
+ (overlay-put (make-overlay beg-sub (+ beg-sub 1))
+ 'before-string
+ (concat "[" (number-to-string sig-lines)
+ "-line signature.]"))
+ (overlay-put (make-overlay (+ beg-sub 2) end)
+ 'invisible 'notmuch-show-signature)
+ (goto-char end)))))
+ (forward-line))))
(defun notmuch-show-markup-body ()
(re-search-forward notmuch-show-body-begin-regexp)
(progn
(notmuch-show-next-unread-message)
; But if there are no unread messages, go back to the
- ; beginning of the buffer.
+ ; beginning of the buffer, and open up the bodies of all
+ ; read message.
(if (not (notmuch-show-message-unread-p))
- (goto-char (point-min)))))
+ (progn
+ (goto-char (point-min))
+ (notmuch-show-toggle-body-read-visible)))))
)))
(defvar notmuch-search-mode-map