diff --git a/.emacs b/.emacs index 19fc43750c8e7a90fa15a37f1de11cf04a73d08c..c0bf32f424a057d184bc2d7fdcb8f13bd7247c9c 100644 --- a/.emacs +++ b/.emacs @@ -1074,6 +1074,43 @@ ;; le code décimal) (global-set-key [181] 'mailcut) +(defvar scissors ">8 --------------------------------------------------------------- 8<" +"String to insert in \\[scissors].") +(defun scissors() + "Insert a line of SCISSORS in the buffer" + (interactive) + (insert scissors) + (forward-line 1)) +(global-set-key (kbd "M-s s") 'scissors) + +(defun snip-lines-mail () + "Delete all lines except the first three in the current buffer selection. +For the first and last remaining lines, remove all characters after the prefix composed of spaces and '>'. +For the middle line, remove all characters after the prefix and insert '[snip]' after the remaining prefix." + (interactive) + (save-excursion + (let ((begin (region-beginning)) + (end (region-end))) + (goto-char end) + (forward-line -1) + (setq end (point)) + (goto-char begin) + (forward-line 2) + (setq begin (point)) + (delete-region begin end) + (goto-char begin) + (forward-line -2) + (if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t) + (replace-match "" nil nil nil 2)) + (forward-line 1) + (if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t) + (replace-match "[snip]" nil nil nil 2)) + (forward-line 1) + (if (re-search-forward "^\\([ >]*\\)\\(.*\\)$" nil t) + (replace-match "" nil nil nil 2)) + (forward-line 1)))) +(global-set-key (kbd "M-s l") 'snip-lines-mail) + ;;; .emacs ends here (provide '.emacs)