Gnus development mailing list
 help / color / mirror / Atom feed
From: Andreas Fuchs <asf@acm.org>
Subject: [OT] patch for tc.el: remove empty quoted lines
Date: Sun, 21 Jan 2001 13:48:48 +0100	[thread overview]
Message-ID: <E14KJvM-0002M3-00@dahaIM.dyndns.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Hi.

First off, sorry for being offtopic, but the tc mailing list does not
seem to answer to my subscription request. I know that many gnus users
also use tc, so I'll just post this here.

I have been annoyed by tc's behavior (leaving empty lines that mark the
end of a paragraph hanging around with a "> ") long enough now that I
made a small patch to tc.el:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tc-remove-empty.patch --]
[-- Type: text/x-patch, Size: 2088 bytes --]

--- tc.el	Tue Oct 31 19:10:26 2000
+++ .elisp/tc.el	Sun Jan 21 09:51:10 2001
@@ -483,6 +500,23 @@
 Normally, tc-max-lines is set to limit the citation of very long mails (e.g.
 citations).")
 
+(defvar tc-remove-empty-lines t
+
+  "*Whether empty cited lines should be removed before filling. Thus,
+paragraphs that would (when set to nil) look like:
+
+> foo
+>
+> bar
+
+look like:
+
+> foo
+
+> bar
+
+when set to t.")
+
 (defun tc-indent-region (start end)
   "*Cite the region like trivial-cite, but without parsing headers.
 Doesn't cut the signature either."
@@ -526,7 +560,8 @@
         (add-hook 'mail-citation-hook 'trivial-cite)
 Bugs:  Not very intelligent about old citation marks other than '>'.
 Customization:  See variables tc-fill-long-lines, tc-remove-signature,
-tc-citation-string, tc-make-attribution and tc-header-funs."
+tc-citation-string, tc-make-attribution, tc-remove-empty-lines and
+tc-header-funs."
   (save-excursion
     (let ((start (point)))
       ;; Initialize some fields
@@ -568,6 +603,9 @@
       (setq tc-cite-marks (escape-char-range tc-cite-marks))
       ;; Do the actual citation
       (tc-indent-citation)
+      ;; remove empty citation lines
+      (if tc-remove-empty-lines
+	  (tc-remove-empty-lines start (mark-marker)))
       ;; Fill paragraphs
       (if tc-fill-long-lines
 	  (tc-fill-cited-text start (mark-marker)))
@@ -580,6 +618,19 @@
 ;;; ************************************************************
 ;;; Reformatting cited text
 ;;; ************************************************************
+
+(defun tc-remove-empty-lines (begin end)
+  "Remove all \"empty\" lines (those which have only the cite mark on them)
+from the citation."
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region begin end)
+      (goto-char (point-min))
+      (while (re-search-forward (concat "^\\(" tc-citation-string " *\\)+$") (point-max) t)
+	(beginning-of-line)
+	(kill-line)))))
+	
 
 (defun tc-fill-cited-paragraphs (cite-len)
   "Fill cited paragraphs, keeping cite-marks in their correct places.  Used

[-- Attachment #3: Type: text/plain, Size: 467 bytes --]


This removes all text on cited paragraph break lines, so stuff like:

>> foo
>> 
>> bar
>
> baz

looks like:

>> foo

>> bar

> baz

which should be just the behavior you know from supercite.

There is just one problem with this thing: It does not detect lines that
are using a cite prefix other than ">". Otherwise, it works just
fine[tm] for me.

Enjoy (as always, comments are very appreciated),
-- 
Andreas Fuchs, <asf@acm.org>, <d96001@htlwrn.ac.at>, antifuchs

                 reply	other threads:[~2001-01-21 12:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E14KJvM-0002M3-00@dahaIM.dyndns.org \
    --to=asf@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).