From c8ecf83e3e0bb79dfb92db1121f6738698a34baa Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 24 Jul 2013 18:03:11 -0400 Subject: Add function to snip mail quote --- init/km-gnus.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/init/km-gnus.el b/init/km-gnus.el index 586b059..2a5324a 100644 --- a/init/km-gnus.el +++ b/init/km-gnus.el @@ -148,3 +148,37 @@ fetches level ARG regardless of whether gnus was already running" (global-set-key (kbd "C-x m") '(lambda () (interactive) (km/gnus-other-frame-always-fetch 1))) + +;; modified from +;; http://emacs-fu.blogspot.com/2008/12/some-simple-tricks-boxquote-footnote.html +(defun km/snip-mail-quote (beg end &optional quote-char no-number) + "Replace region lines with \"[n lines ...]\". + +The default QUOTE-CHAR is \">\". Text following the snipped lines +is placed on a new line and the resulting paragraph is filled. If +NO-NUMBER is non-nil, the number of lines is not added." + (interactive "r") + (let ((nlines (count-lines beg end)) + (quote-char (or quote-char ">"))) + (delete-region beg end) + (if no-number + (insert (format "[...]")) + (insert (format "[%d line%s ...]" nlines (if (= 1 nlines) "" "s")))) + (search-backward "[") + (unless (bolp) + (newline)) + (search-forward "]") + (unless (eolp) + (newline) + (insert quote-char) + (just-one-space) + (fill-paragraph)))) + +(define-key message-mode-map + (kbd "C-c m s") 'km/snip-mail-quote) + +;; without reporting the number of lines +(define-key message-mode-map + (kbd "C-c m S") '(lambda (beg end) + (interactive "r") + (km/snip-mail-quote beg end nil t))) -- cgit v1.2.3