Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Yuri D'Elia <wavexx@users.sf.net>
To: info-gnus-english@gnu.org
Subject: More on format=flowed
Date: Sun, 02 Jan 2011 16:59:20 +0100	[thread overview]
Message-ID: <87ipy72t5z.fsf@savara.sat.thregr.org> (raw)

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?

             reply	other threads:[~2011-01-02 15:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-02 15:59 Yuri D'Elia [this message]
     [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

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=87ipy72t5z.fsf@savara.sat.thregr.org \
    --to=wavexx@users.sf.net \
    --cc=info-gnus-english@gnu.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).