help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cite (comment) in message mode


From: Emanuel Berg
Subject: cite (comment) in message mode
Date: Thu, 14 Dec 2017 08:07:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Another quality release from The Secret Empire.

Now you can set the comment non-DWIM style with
C-u. So C-u 0 removes comment(s) and above that
it nests up...

(defun message-cite-region (beg end &optional levels)
  (interactive "*r\np")
  (goto-char beg)
  (beginning-of-line)
  (let*((first-line (line-number-at-pos))
        (last-line  (line-number-at-pos end))
        (num-lines  (1+ (- last-line first-line))) )
    (dotimes (unused num-lines)
      (while (looking-at ">") (delete-char 1)) ; TODO: away hard-code
      (when  (looking-at " ") (delete-char 1))
      (when (> levels 0)
        (insert-char ?> levels)
        (insert-char ?\ ) ) ; this repairs ugly >quotes as well
      (forward-line 1) )
    ;; clean up
    (goto-char (point-min))
    (forward-line (1- last-line))
    (end-of-line)
    (when (region-active-p) (keyboard-quit)) ))
(defalias 'mcr 'message-cite-region) ; or bind to M-; in message-mode

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]