notmuch.el: Add 'w' binding to view raW email message.

This takes advantage of the new filename output just added to "notmuch
show".
This commit is contained in:
Carl Worth 2009-11-04 15:53:41 -08:00
parent b1baaab2d5
commit 988320ad74

View file

@ -38,6 +38,7 @@
(define-key map (kbd "C-p") 'notmuch-show-previous-line) (define-key map (kbd "C-p") 'notmuch-show-previous-line)
(define-key map "q" 'kill-this-buffer) (define-key map "q" 'kill-this-buffer)
(define-key map "s" 'notmuch-show-toggle-signatures-visible) (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 "x" 'kill-this-buffer)
(define-key map "+" 'notmuch-show-add-tag) (define-key map "+" 'notmuch-show-add-tag)
(define-key map "-" 'notmuch-show-remove-tag) (define-key map "-" 'notmuch-show-remove-tag)
@ -61,7 +62,8 @@
(set 'notmuch-show-part-end-regexp " part}") (set 'notmuch-show-part-end-regexp " part}")
(set 'notmuch-show-marker-regexp " \\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$") (set 'notmuch-show-marker-regexp " \\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$")
(set 'notmuch-show-id-regexp "ID: \\(.*\\)$") (set 'notmuch-show-id-regexp "ID: \\([^ ]*\\)")
(set 'notmuch-show-filename-regexp "Filename: \\(.*\\)$")
(set 'notmuch-show-tags-regexp "(\\([^)]*\\))$") (set 'notmuch-show-tags-regexp "(\\([^)]*\\))$")
; XXX: This should be a generic function in emacs somewhere, not here ; XXX: This should be a generic function in emacs somewhere, not here
@ -110,6 +112,14 @@ Unlike builtin `next-line' this version accepts no arguments."
(re-search-forward notmuch-show-id-regexp) (re-search-forward notmuch-show-id-regexp)
(buffer-substring (match-beginning 1) (match-end 1)))) (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) (defun notmuch-show-set-tags (tags)
(save-excursion (save-excursion
(beginning-of-line) (beginning-of-line)
@ -171,6 +181,11 @@ buffer."
(switch-to-buffer parent-buffer) (switch-to-buffer parent-buffer)
(notmuch-search-show-thread))))) (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 () (defun notmuch-show-move-to-current-message-summary-line ()
"Move to the beginning of the one-line summary of the current message. "Move to the beginning of the one-line summary of the current message.