X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;ds=sidebyside;f=notmuch.el;h=68a01187820d74849ec29d920c5ecfdaaae6e90b;hb=b7366f80525aa0b0c7ab42f8b378cf46389438a4;hp=20436f83a5ca5a89f3b4c3e4cdee4f82a7af4bc5;hpb=97b5f8153399d57bb9db643e778b06e23387110c;p=notmuch diff --git a/notmuch.el b/notmuch.el index 20436f83..68a01187 100644 --- a/notmuch.el +++ b/notmuch.el @@ -38,9 +38,11 @@ (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) + (define-key map (kbd "DEL") 'notmuch-show-rewind) (define-key map " " 'notmuch-show-advance-marking-read-and-archiving) map) "Keymap for \"notmuch show\" buffers.") @@ -49,20 +51,21 @@ (defvar notmuch-show-signature-lines-max 6 "Maximum length of signature that will be hidden by default.") -(defvar notmuch-show-message-begin-regexp " message{") -(defvar notmuch-show-message-end-regexp " message}") -(defvar notmuch-show-header-begin-regexp " header{") -(defvar notmuch-show-header-end-regexp " header}") -(defvar notmuch-show-body-begin-regexp " body{") -(defvar notmuch-show-body-end-regexp " body}") -(defvar notmuch-show-attachment-begin-regexp " attachment{") -(defvar notmuch-show-attachment-end-regexp " attachment}") -(defvar notmuch-show-part-begin-regexp " part{") -(defvar notmuch-show-part-end-regexp " part}") -(defvar notmuch-show-marker-regexp " \\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$") - -(defvar notmuch-show-id-regexp "ID: \\(.*\\)$") -(defvar notmuch-show-tags-regexp "(\\([^)]*\\))$") +(set 'notmuch-show-message-begin-regexp " message{") +(set 'notmuch-show-message-end-regexp " message}") +(set 'notmuch-show-header-begin-regexp " header{") +(set 'notmuch-show-header-end-regexp " header}") +(set 'notmuch-show-body-begin-regexp " body{") +(set 'notmuch-show-body-end-regexp " body}") +(set 'notmuch-show-attachment-begin-regexp " attachment{") +(set 'notmuch-show-attachment-end-regexp " attachment}") +(set 'notmuch-show-part-begin-regexp " part{") +(set 'notmuch-show-part-end-regexp " part}") +(set 'notmuch-show-marker-regexp " \\(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 () @@ -110,6 +113,14 @@ Unlike builtin `next-line' this version accepts no arguments." (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) @@ -171,6 +182,11 @@ buffer." (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. @@ -257,12 +273,48 @@ simply move to the beginning of the current message." )) (recenter 0))) +(defun notmuch-show-find-previous-message () + "Returns the position of the previous message in the buffer. + +Or the position of the beginning of the current message if point +is originally within the message rather than at the beginning of +it." + ; save-excursion doesn't save our window position + ; save-window-excursion doesn't save point + ; Looks like we have to use both. + (save-excursion + (save-window-excursion + (notmuch-show-previous-message) + (point)))) + (defun notmuch-show-mark-read-then-next-unread-message () "Remove unread tag from current message, then advance to next unread message." (interactive) (notmuch-show-remove-tag "unread") (notmuch-show-next-unread-message)) +(defun notmuch-show-rewind () + "Do reverse scrolling compared to `notmuch-show-advance-marking-read-and-archiving' + +Specifically, if the beginning of the previous email is fewer +than `window-height' lines from the current point, move to it +just like `notmuch-show-previous-message'. + +Otherwise, just scroll down a screenful of the current message. + +This command does not modify any message tags, (it does not undo +any effects from previous calls to +`notmuch-show-advance-marking-read-and-archiving'." + (interactive) + (let ((previous (notmuch-show-find-previous-message))) + (if (> (count-lines previous (point)) (- (window-height) next-screen-context-lines)) + (progn + (condition-case nil + (scroll-down nil) + ((beginning-of-buffer) nil)) + (goto-char (window-start))) + (notmuch-show-previous-message)))) + (defun notmuch-show-advance-marking-read-and-archiving () "Advance through buffer, marking read and archiving.