From ae25096db65306f3f1a580e367abafcd81bd3018 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Thu, 9 Jan 2014 18:07:48 +0100 Subject: [PATCH] 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. --- mu4e/mu4e-compose.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 19b3e63a..8ccb97e2 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -589,6 +589,36 @@ Ie. either 'name ' 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