unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Reformatting Chat Protocol?
@ 2010-11-14 14:42 Felix E. Klee
       [not found] ` <87mxpcnefv.fsf@kuiper.lan.informatimago.com>
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Felix E. Klee @ 2010-11-14 14:42 UTC (permalink / raw)
  To: help-gnu-emacs

In a text file, I want to reformat a block as follows. Its a chat
protocol with various lines longer than the value of `fill-column'.

From:

  [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
bla bla bla bla bla bla bla bla bla bla
  [11.11.2010 17:04:21] bla bla bla bla bla
  [11.11.2010 17:05:25] bla bla bla

Into:

  [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
    bla bla bla bla bla bla bla bla bla bla
  [11.11.2010 17:04:21] bla bla bla bla bla bla bla bla bla
  [11.11.2010 17:05:25] bla bla bla

Or:

  [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
                        bla bla bla bla bla bla bla bla bla bla
  [11.11.2010 17:04:21] bla bla bla bla bla bla bla bla bla
  [11.11.2010 17:05:25] bla bla bla

Any simple solution?


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

* Re: Reformatting Chat Protocol?
       [not found]   ` <5084d90b-b875-43cd-bbfe-ffa75d320ebb@a30g2000vbt.googlegroups.com>
@ 2010-11-14 15:43     ` Pascal J. Bourguignon
  0 siblings, 0 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2010-11-14 15:43 UTC (permalink / raw)
  To: help-gnu-emacs

"Felix E. Klee" <felix.klee@inka.de> writes:

> On Nov 14, 3:54 pm, p...@informatimago.com (Pascal J. Bourguignon)
> wrote:
>> M-< M-x replace-regexp RET ^\([^]]\) RET C-u 24 SPC \1 RET
>
> Thanks for the suggestion. However, this does not do the trick - I
> have
> forgotten to mention explicitly:
>
>   The second line in the "From"-block in my original posting is a
>   continuation of the first line. The line break has only been
>   inserted
>   for better readability in news readers. Actually, that block only
>   consists of three lines.

So what?

> Any further suggestions?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


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

* Re: Reformatting Chat Protocol?
  2010-11-14 14:42 Reformatting Chat Protocol? Felix E. Klee
       [not found] ` <87mxpcnefv.fsf@kuiper.lan.informatimago.com>
@ 2010-11-14 20:24 ` Andreas Politz
  2010-11-14 21:30 ` Felix E. Klee
  2010-11-17  2:27 ` Stefan Monnier
  3 siblings, 0 replies; 5+ messages in thread
From: Andreas Politz @ 2010-11-14 20:24 UTC (permalink / raw)
  To: help-gnu-emacs

"Felix E. Klee" <felix.klee@inka.de> writes:

> In a text file, I want to reformat a block as follows. Its a chat
> protocol with various lines longer than the value of `fill-column'.
>
> From:
>
>   [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
> bla bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:04:21] bla bla bla bla bla
>   [11.11.2010 17:05:25] bla bla bla
>
> Into:
>
>   [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
>     bla bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:04:21] bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:05:25] bla bla bla
>
> Or:
>
>   [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
>                         bla bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:04:21] bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:05:25] bla bla bla
>
> Any simple solution?

Try this, i.e. evaluate it in the chat buffer.

(progn
  (mapc 'make-local-variable '(paragraph-start paragraph-separate))
  (setq paragraph-start "\\["
        paragraph-separate "$"
        fill-prefix (make-string (length "[11.11.2010 17:05:25] ")
                                 ?\s))
  (fill-region (point-min) (point-max)))

-ap


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

* Re: Reformatting Chat Protocol?
  2010-11-14 14:42 Reformatting Chat Protocol? Felix E. Klee
       [not found] ` <87mxpcnefv.fsf@kuiper.lan.informatimago.com>
  2010-11-14 20:24 ` Andreas Politz
@ 2010-11-14 21:30 ` Felix E. Klee
  2010-11-17  2:27 ` Stefan Monnier
  3 siblings, 0 replies; 5+ messages in thread
From: Felix E. Klee @ 2010-11-14 21:30 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks for all the suggestions! In a quiet moment and without Internet
access, I now had a look at the EMACS info pages. What I discovered:
Setting the variables "paragraph-start" and "fill-prefix", for example
in the "Local Variables" block, does the trick. Then I can simply use
M-q to get the format I want.

My current setting:

  paragraph-start: "\[[0-9. :]*\]"
  fill-prefix: "  "


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

* Re: Reformatting Chat Protocol?
  2010-11-14 14:42 Reformatting Chat Protocol? Felix E. Klee
                   ` (2 preceding siblings ...)
  2010-11-14 21:30 ` Felix E. Klee
@ 2010-11-17  2:27 ` Stefan Monnier
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2010-11-17  2:27 UTC (permalink / raw)
  To: help-gnu-emacs

> In a text file, I want to reformat a block as follows. Its a chat
> protocol with various lines longer than the value of `fill-column'.

> From:

>   [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
> bla bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:04:21] bla bla bla bla bla
>   [11.11.2010 17:05:25] bla bla bla

> Into:

>   [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
>     bla bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:04:21] bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:05:25] bla bla bla

> Or:

>   [11.11.2010 17:01:37] bla bla bla bla bla bla bla bla bla bla bla
>                         bla bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:04:21] bla bla bla bla bla bla bla bla bla
>   [11.11.2010 17:05:25] bla bla bla

> Any simple solution?

I think you've found the simple solution already, but if you want to get
"fancy", you can actually teach Emacs how to display those long lines
without actually changing the file (i.e. they'll still be continuation
lines and the wrapping will dynamically adjust to the window width, but
they'll be indented like you want them to be).

The simple way is:  (setq wrap-prefix "    ")
If the wrap-prefix needs to be different for different parts of the
file, it can also be accommodated, tho it's more complex in that case
since you need to set text-properties on each and every line.


        Stefan


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

end of thread, other threads:[~2010-11-17  2:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-14 14:42 Reformatting Chat Protocol? Felix E. Klee
     [not found] ` <87mxpcnefv.fsf@kuiper.lan.informatimago.com>
     [not found]   ` <5084d90b-b875-43cd-bbfe-ffa75d320ebb@a30g2000vbt.googlegroups.com>
2010-11-14 15:43     ` Pascal J. Bourguignon
2010-11-14 20:24 ` Andreas Politz
2010-11-14 21:30 ` Felix E. Klee
2010-11-17  2:27 ` Stefan Monnier

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 read-only IMAP folder(s) and NNTP newsgroup(s).