Better M-< and M-> when composing a message.

This commit provides the following 2 functions that help the user go to
interesting positions at the beginning and end of the message being
composed. These 2 functions are bound to the standard `M-<` and `M->`
keys (or more precisely, to the keys where 'beginning-of-buffer and
'end-of-buffer are bound).

mu4e-compose-goto-top: Go to the beginning of the message or buffer.
  Go to the beginning of the message or, if already there, go to the
  beginning of the buffer.

mu4e-compose-goto-bottom Go to the end of the message or buffer.
  Go to the end of the message (before signature) or, if already there,
  go to the end of the buffer.
This commit is contained in:
Damien Cassou
2014-01-09 18:07:48 +01:00
parent 91f9892814
commit ae25096db6

View File

@ -589,6 +589,36 @@ Ie. either 'name <email>' or 'email')."
(message-goto-body)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-compose-goto-top ()
"Go to the beginning of the message or buffer.
Go to the beginning of the message or, if already there, go to the
beginning of the buffer."
(interactive)
(let ((old-position (point)))
(message-goto-body)
(when (equal (point) old-position)
(beginning-of-buffer))))
(define-key mu4e-compose-mode-map
(vector 'remap 'beginning-of-buffer) 'mu4e-compose-goto-top)
(defun mu4e-compose-goto-bottom ()
"Go to the end of the message or buffer.
Go to the end of the message (before signature) or, if already there, go to the
end of the buffer."
(interactive)
(let ((old-position (point))
(message-position (save-excursion (message-goto-body) (point))))
(end-of-buffer)
(when (re-search-backward "^-- $" message-position t)
(previous-line))
(when (equal (point) old-position)
(end-of-buffer))))
(define-key mu4e-compose-mode-map
(vector 'remap 'end-of-buffer) 'mu4e-compose-goto-bottom)
(provide 'mu4e-compose)
;; Load mu4e completely even when this file was loaded through