Gnus development mailing list
 help / color / mirror / Atom feed
* [OT] patch for tc.el: remove empty quoted lines
@ 2001-01-21 12:48 Andreas Fuchs
  0 siblings, 0 replies; only message in thread
From: Andreas Fuchs @ 2001-01-21 12:48 UTC (permalink / 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-01-21 12:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-21 12:48 [OT] patch for tc.el: remove empty quoted lines Andreas Fuchs

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).