(defun quote-region (start end &optional string) (interactive "r") ; start and end are region endpoints (or string (if (boundp 'quoted-text-prefix) (setq string quoted-text-prefix) (setq string ">"))) (let ((len (length string))) (save-excursion (goto-char start) (or (bolp) (progn (insert "\n") ; force newline at start of region (setq end (1+ end)))) (while (< (point) end) (insert string) (setq end (+ end len)) ; insertion changed endpoint (beginning-of-line 2)) ))) ; beginning of next line (defun unquote-region (start end &optional string) (interactive "r") (or string (if (boundp 'quoted-text-chars) (setq string quoted-text-chars) (setq string "><\]\[:;\\|# \t"))) (let ((re (concat "^[" string ; (regexp-quote string) "]"))) (save-excursion (goto-char start) (beginning-of-line) ; start at beginning of first line of region (while (< (point) end) (cond ((looking-at re) (delete-char 1) (1- end))) (beginning-of-line 2)) )))