Skip to content
Snippets Groups Projects
Commit bccd4129 authored by Philippe Dosch's avatar Philippe Dosch
Browse files

scissors et snip-lines-mail définis

parent 6fb061df
No related branches found
No related tags found
No related merge requests found
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment