Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Re: More on format=flowed
       [not found] <mailman.0.1293983977.14417.info-gnus-english@gnu.org>
@ 2011-01-02 19:32 ` Lars Magne Ingebrigtsen
  2011-01-03  0:55   ` Yuri D'Elia
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-01-02 19:32 UTC (permalink / raw)
  To: info-gnus-english

Yuri D'Elia <wavexx@users.sf.net> writes:

> (defun harden-newlines ()
>   (save-excursion
>     (goto-char (point-min))
>     (while (search-forward "\n" nil t)
>       (put-text-property (1- (point)) (point) 'hard t))))

So, basically, you make all the newlines hard.  Isn't the point of
`use-hard-newlines' that you can mix and match hard and soft newlines?

That is:

[...]

> 	word-wrap t
> 	use-hard-newlines t))))

You're mixing `use-hard-newlines' with `word-wrap', and the two don't
really mix that well.  I think.

(I've never used either.)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: More on format=flowed
  2011-01-02 19:32 ` More on format=flowed Lars Magne Ingebrigtsen
@ 2011-01-03  0:55   ` Yuri D'Elia
  0 siblings, 0 replies; 3+ messages in thread
From: Yuri D'Elia @ 2011-01-03  0:55 UTC (permalink / raw)
  To: info-gnus-english

On Sun, 02 Jan 2011 20:32:31 +0100, Lars Magne Ingebrigtsen wrote:
>> (defun harden-newlines ()
>>   (save-excursion
>>     (goto-char (point-min))
>>     (while (search-forward "\n" nil t)
>>       (put-text-property (1- (point)) (point) 'hard t))))
>
> So, basically, you make all the newlines hard.  Isn't the point of
> `use-hard-newlines' that you can mix and match hard and soft newlines?

I guess the point of `use-hard-newlines' is to preserve the concept of
soft and hard newlines when the text is being automatically manipulated
by auto-fill.

Just as a note, `longlines-mode' is a twist on the concept that performs
word wrapping with soft newlines, but stores hard newlines only
(simulating the effect of word-wrap). Is this mode still needed at all?

The point of format=flowed is to have flowed text however, when reading
*and* writing if the user so desires.

For instance, when a flowed message is decoded in flow-fill.el, hard
newlines aren't restored. This means that you can't actually make *use*
of the distinction (a cheap hack would have been turning on
`longlines-mode' in the article buffer with mixed hard/soft newlines).

At least with `fill-flowed-display-column' I can force the unquoting so
that I can still use word-wrap, but that's sub-optimal. Either fully
support soft newlines, or use word-wrap and be done.

>> 	word-wrap t
>> 	use-hard-newlines t))))
>
> You're mixing `use-hard-newlines' with `word-wrap', and the two don't
> really mix that well.  I think.

Turning `use-hard-newlines' on is just a hack to force Gnus into
generating a flowed message.

Internally `fill-flowed-encode' unwraps all soft newlines and then
rewraps then using `fill-region'. That's completely unnecessary with
word-wrap (there are no more soft newlines). I simply skip the first
step by marking all lines as hard.

When lines longer than `message-fill-column' are seen, the body should be
encoded automatically with format=flowed, or quoted-printable. But I
can't see any variable that can regulate the final message encoding.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* More on format=flowed
@ 2011-01-02 15:59 Yuri D'Elia
  0 siblings, 0 replies; 3+ messages in thread
From: Yuri D'Elia @ 2011-01-02 15:59 UTC (permalink / raw)
  To: info-gnus-english

In my quest for format=flowed, I *think* I've come up with a workable
solution by using the following:

---

(defun harden-newlines ()
  (save-excursion
    (goto-char (point-min))
    (while (search-forward "\n" nil t)
      (put-text-property (1- (point)) (point) 'hard t))))

(setq fill-flowed-display-column nil)

(add-hook 'message-setup-hook
  (lambda ()
    (when message-this-is-mail
      (turn-off-auto-fill)
      (setq
	truncate-lines nil
	word-wrap t
	use-hard-newlines t))))

(add-hook 'message-send-hook
  (lambda ()
    (when use-hard-newlines
      (harden-newlines))))

(add-hook 'gnus-article-mode-hook
  (lambda ()
    (setq
      truncate-lines nil
      word-wrap t)))

---

The idea behind it:

- `fill-flowed-display-column' will unwrap flowed message as expected.
  Apparently, the current code in flow-fill.el has problems with long
  quoted text (not all lines are correctly unfolded, but this doesn't
  affect the usability of the message).

- `gnus-article-mode-hook' will wrap flowed messages using word-wrap
  instead. This works nicely.

- In `message-setup-hook' again we turn on the built-in worp-wrap,
  disable auto-fill and set use-hard-newlines silently. Those are set
  for mail messages only, though I've verified that flowed messages also
  work on gmane groups (gmane.test).

- The magic is really done i `message-send-hook', where all newlines are
  replaced with hard newlines. This way the existing message, and more
  importantly, pasted text lacking 'hard' newlines will be preserved.

  All long lines will be wrapped at `fill-flowed-encode-column' since
  `use-hard-newlines' was already turned on earlier.

That's *much* harder than calling (use-hard-newlines) to use
format=flowed all around. Yet, it seems to work. Maybe.

Comments?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-03  0:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.0.1293983977.14417.info-gnus-english@gnu.org>
2011-01-02 19:32 ` More on format=flowed Lars Magne Ingebrigtsen
2011-01-03  0:55   ` Yuri D'Elia
2011-01-02 15:59 Yuri D'Elia

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