-(defun notmuch-show-reply ()
- "Begin composing a reply to the current message in a new buffer."
- (interactive)
- (let ((message-id (notmuch-show-get-message-id)))
- (notmuch-reply message-id)))
-
-(defun notmuch-show-forward-current ()
- "Forward the current message."
- (interactive)
- (with-current-notmuch-show-message
- (message-forward)))
-
-(defun notmuch-show-pipe-message (command)
- "Pipe the contents of the current message to the given command.
-
-The given command will be executed with the raw contents of the
-current email message as stdin. Anything printed by the command
-to stdout or stderr will appear in the *Messages* buffer."
- (interactive "sPipe message to command: ")
- (apply 'start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*"
- (list command " < " (shell-quote-argument (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.
-
-This gives us a stable place to move to and work from since the
-summary line is always visible. This is important since moving to
-an invisible location is unreliable, (the main command loop moves
-point either forward or backward to the next visible character
-when a command ends with point on an invisible character).
-
-Emits an error if point is not within a valid message, (that is
-no pattern of `notmuch-show-message-begin-regexp' could be found
-by searching backward)."
- (beginning-of-line)
- (if (not (looking-at notmuch-show-message-begin-regexp))
- (if (re-search-backward notmuch-show-message-begin-regexp nil t)
- (forward-line 2)
- (error "Not within a valid message."))
- (forward-line 2)))
-
-(defun notmuch-show-last-message-p ()
- "Predicate testing whether point is within the last message."
- (save-window-excursion
- (save-excursion
- (notmuch-show-move-to-current-message-summary-line)
- (not (re-search-forward notmuch-show-message-begin-regexp nil t)))))
-
-(defun notmuch-show-message-unread-p ()
- "Predicate testing whether current message is unread."
- (member "unread" (notmuch-show-get-tags)))
-
-(defun notmuch-show-message-open-p ()
- "Predicate testing whether current message is open (body is visible)."
- (let ((btn (previous-button (point) t)))
- (while (not (button-has-type-p btn 'notmuch-button-body-toggle-type))
- (setq btn (previous-button (button-start btn))))
- (not (invisible-p (button-get btn 'invisibility-spec)))))
-
-(defun notmuch-show-next-message-without-marking-read ()
- "Advance to the beginning of the next message in the buffer.
-
-Moves to the last visible character of the current message if
-already on the last message in the buffer.
-
-Returns nil if already on the last message in the buffer."
- (notmuch-show-move-to-current-message-summary-line)
- (if (re-search-forward notmuch-show-message-begin-regexp nil t)
- (progn
- (notmuch-show-move-to-current-message-summary-line)
- (recenter 0)
- t)
- (goto-char (- (point-max) 1))
- (while (point-invisible-p)
- (backward-char))
- (recenter 0)
- nil))
-
-(defun notmuch-show-next-message ()
- "Advance to the next message (whether open or closed)
-and remove the unread tag from that message.
-
-Moves to the last visible character of the current message if
-already on the last message in the buffer.
-
-Returns nil if already on the last message in the buffer."
- (interactive)
- (notmuch-show-next-message-without-marking-read)
- (notmuch-show-mark-read))
-
-(defun notmuch-show-find-next-message ()
- "Returns the position of the next message in the buffer.
-
-Or the position of the last visible character of the current
-message if already within the last message in the buffer."
- ; 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-next-message-without-marking-read)
- (point))))
-
-(defun notmuch-show-next-unread-message ()
- "Advance to the next unread message.
-
-Moves to the last visible character of the current message if
-there are no more unread messages past the current point."
- (notmuch-show-next-message-without-marking-read)
- (while (and (not (notmuch-show-last-message-p))
- (not (notmuch-show-message-unread-p)))
- (notmuch-show-next-message-without-marking-read))
- (if (not (notmuch-show-message-unread-p))
- (notmuch-show-next-message-without-marking-read))
- (notmuch-show-mark-read))
-
-(defun notmuch-show-next-open-message ()
- "Advance to the next open message (that is, body is visible).
-
-Moves to the last visible character of the final message in the buffer
-if there are no more open messages."
- (interactive)
- (while (and (notmuch-show-next-message-without-marking-read)
- (not (notmuch-show-message-open-p))))
- (notmuch-show-mark-read))
-
-(defun notmuch-show-previous-message-without-marking-read ()
- "Backup to the beginning of the previous message in the buffer.
-
-If within a message rather than at the beginning of it, then
-simply move to the beginning of the current message.
-
-Returns nil if already on the first message in the buffer."
- (let ((start (point)))
- (notmuch-show-move-to-current-message-summary-line)
- (if (not (< (point) start))
- ; Go backward twice to skip the current message's marker
- (progn
- (re-search-backward notmuch-show-message-begin-regexp nil t)
- (re-search-backward notmuch-show-message-begin-regexp nil t)
- (notmuch-show-move-to-current-message-summary-line)
- (recenter 0)
- (if (= (point) start)
- nil
- t))
- (recenter 0)
- nil)))
-
-(defun notmuch-show-previous-message ()
- "Backup to the previous message (whether open or closed)
-and remove the unread tag from that message.
-
-If within a message rather than at the beginning of it, then
-simply move to the beginning of the current message."
- (interactive)
- (notmuch-show-previous-message-without-marking-read)
- (notmuch-show-mark-read))
-
-(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-without-marking-read)
- (point))))
-
-(defun notmuch-show-previous-open-message ()
- "Backup to previous open message (that is, body is visible).
-
-Moves to the first message in the buffer if there are no previous
-open messages."
- (interactive)
- (while (and (notmuch-show-previous-message-without-marking-read)
- (not (notmuch-show-message-open-p))))
- (notmuch-show-mark-read))
-
-(defun notmuch-show-rewind ()
- "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).
-
-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-and-archive'."
- (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))
- ; Because count-lines counts invivisible lines, we may have
- ; scrolled to far. If so., notice this and fix it up.
- (if (< (point) previous)
- (progn
- (goto-char previous)
- (recenter 0))))
- (notmuch-show-previous-message))))
-
-(defun notmuch-show-advance-and-archive ()
- "Advance through thread and archive.
-
-This command is intended to be one of the simplest ways to
-process a thread of email. It does the following:
-
-If the current message in the thread is not yet fully visible,
-scroll by a near screenful to read more of the message.
-
-Otherwise, (the end of the current message is already within the
-current window), advance to the next open message.
-
-Finally, if there is no further message to advance to, and this
-last message is already read, then archive the entire current
-thread, (remove the \"inbox\" tag from each message). Also kill
-this buffer, and display the next thread from the search from
-which this thread was originally shown."
- (interactive)
- (let ((next (notmuch-show-find-next-message))
- (unread (notmuch-show-message-unread-p)))
- (if (> next (window-end))
- (scroll-up nil)
- (let ((last (notmuch-show-last-message-p)))
- (notmuch-show-next-open-message)
- (if last
- (notmuch-show-archive-thread))))))
-
-(defun notmuch-show-next-button ()
- "Advance point to the next button in the buffer."
- (interactive)
- (forward-button 1))
-
-(defun notmuch-show-previous-button ()
- "Move point back to the previous button in the buffer."
- (interactive)
- (backward-button 1))
-