summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-07-21 11:10:39 +0200
committerGuido Günther <agx@sigxcpu.org>2017-07-21 11:10:39 +0200
commitf73af44dc0db7e6667ec743d751b14877454c538 (patch)
treefb6e7f1d8f0b59329751beabd1509cb1de521d7f
parent2028d7a5548fb9cae641e45dc6f3a659f3b1839a (diff)
Make composing new mails simpler
* skip headers * inserert greeting * move to first quotable block in replies
-rw-r--r--mail.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/mail.el b/mail.el
new file mode 100644
index 0000000..906ac1f
--- /dev/null
+++ b/mail.el
@@ -0,0 +1,38 @@
+;; simplify mail handling
+(defun _xcpu-current-line-empty-p ()
+ (eq 0 (string-match-p "^$" (thing-at-point 'line))))
+
+(defun _xcpu-current-line-banner-p ()
+ (eq 0 (string-match-p "^On" (thing-at-point 'line))))
+
+(defun _xcpu-current-line-quoted-empty-p ()
+ (eq 0 (string-match-p "^\\(> *\\)$" (thing-at-point 'line))))
+
+(defun _xcpu-current-line-quoted-p ()
+ (eq 0 (string-match-p "^\\(> *\\)" (thing-at-point 'line))))
+
+(defun xcpu-reply-mail ()
+ "Skip over header and look for first paragraph to reply to when answering mail"
+ (interactive)
+ (goto-char 1)
+ ;; Skip the email header
+ (while (not (_xcpu-current-line-empty-p))
+ (forward-line 1)
+ (beginning-of-line)
+ )
+ (forward-line 1)
+ ;; Insert greeting if reply or new mail
+ (when (or
+ (_xcpu-current-line-banner-p)
+ (_xcpu-current-line-empty-p))
+ (forward-line -1)
+ (insert "\nHi,")
+ (forward-line 2)
+ ;; search for first quoted line that is empty
+ (when (_xcpu-current-line-quoted-p)
+ (while (not (_xcpu-current-line-quoted-empty-p))
+ (forward-line 1)
+ (beginning-of-line)
+ ))
+ )
+)