Gnus development mailing list
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: "> > >" space removal removes too many spaces?
Date: Sun, 05 Aug 2001 16:47:36 +0200	[thread overview]
Message-ID: <87g0b64l87.fsf@deneb.enyo.de> (raw)
In-Reply-To: <iluelqqehij.fsf@barbar.josefsson.org> (Simon Josefsson's message of "Sun, 05 Aug 2001 15:57:40 +0200")

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

Simon Josefsson <jas@extundo.com> writes:

>> '>' may appear at the beginning of a line accidently, and we certainly
>> want to supply the space character in this case.
> 
> First, wouldn't it be very complicated to solve your case?

No, I don't think so.  I think it helps to consider a leading '>' to
be a quote character only if the preceding line is empty (or consists
entirely of whitespace), or if it starts in turn with a '>'.

I've just implemented this logic (at least I think so).  The diff is a
bit more complicated then it needs to be, but if you don't like this
implementation, I'm going to add some backtracking code which should
do somewhat better.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/diff, Size: 1552 bytes --]

Index: message.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/message.el,v
retrieving revision 6.108
diff -u -r6.108 message.el
--- message.el	2001/07/28 16:43:18	6.108
+++ message.el	2001/08/05 14:26:26
@@ -2100,11 +2100,31 @@
 	(indent-rigidly start (mark t) message-indentation-spaces)
       (save-excursion
 	(goto-char start)
-	(while (< (point) (mark t))
-	  (if (looking-at message-cite-prefix-regexp)
-	      (insert message-yank-cited-prefix)
-	    (insert message-yank-prefix))
-	  (forward-line 1))))
+	(let (last-line)
+	  ;; `last-line' describes the contents of the last line
+	  ;; encountered in the loop below. nil means "empty line",
+	  ;; spaces "line consisting entirely of whitespace",
+	  ;; right-angle "line starts with >", quoted "quote character
+	  ;; at the beginning of the line", text "the remaining cases".
+	  (while (< (point) (mark t))
+	    (cond
+	     ((eolp) 
+	      (insert message-yank-prefix)
+	      (setq last-line nil))
+	     ((looking-at ">")
+	      (if (memq last-line '(nil spaces right-angle quoted))
+		  (progn
+		    (insert message-yank-cited-prefix)
+		    (setq last-line 'quoted))
+		(insert message-yank-prefix)
+		(setq last-line 'right-angle)))
+	     ((looking-at "\\s-+$")
+	      (insert message-yank-prefix)
+	      (setq last-line 'spaces))
+	     (t
+	      (insert message-yank-prefix)
+	      (setq last-line 'text)))
+	    (forward-line 1)))))
     (goto-char start)))
 
 (defun message-yank-original (&optional arg)

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


> I don't see how you programatically can easily separate your case
> from e.g.
> 
>> According to your analysis
>>>42 is a nice number
>> you indicate that 42 is a nice number.
> 
> but suggestions are welcome. :)

Not leaving blank lines before and after quotes is not my preferred
style of writing messages. ;-)

> Secondly, RFC 2646 compliant MUAs should never generate this case in
> the first place.  Even if you don't generate RFC 2646 (Gnus doesn't)
> you could QP encode the character to prevent the ambiguity.

Does RFC 2646 really try to solve the problem this way?  In this
case, the RFC is horribly broken.  Attaching semantic to QP encoding
vs. not-encoding is clearly an extremely bad idea, and it certainly
contradicts the spirit of MIME.

  parent reply	other threads:[~2001-08-05 14:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-05 11:53 Kai Großjohann
2001-08-05 12:05 ` Norbert Koch
2001-08-05 12:15   ` Kai Großjohann
2001-08-05 12:23     ` Norbert Koch
2001-08-05 13:03 ` Simon Josefsson
2001-08-05 13:10   ` Simon Josefsson
2001-08-05 13:46   ` Florian Weimer
2001-08-05 13:57     ` Simon Josefsson
2001-08-05 14:24       ` Nuutti Kotivuori
2001-08-05 14:49         ` Florian Weimer
2001-08-05 21:23           ` Nuutti Kotivuori
2001-08-05 14:47       ` Florian Weimer [this message]
2001-08-05 17:25         ` Kai Großjohann
2001-08-05 17:55           ` Florian Weimer
2001-08-05 19:30         ` Simon Josefsson
2001-08-05 20:11           ` Florian Weimer
2001-08-05 20:45             ` Kai Großjohann
2001-08-05 20:08         ` Kai Großjohann
2001-08-05 23:11   ` Paul Jarc
2001-08-06  6:33     ` Florian Weimer

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=87g0b64l87.fsf@deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    /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).