help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fill comma separated list


From: Kaushal Modi
Subject: Re: fill comma separated list
Date: Thu, 02 Jun 2016 16:08:54 +0000

This works:

With this in a buffer:

5.1816,
-3.81,
4.8768,
5.1816,
-4.4196,
4.8768,
6.4008,
-4.4196,
5.48640,
6.4008,
-3.81,
5.486400;

C-x h ; Mark whole buffer
C-u M-| ; Run shell-command-on-region and replace region with results
paste -d' ' - - -

Do 'man paste' to learn more about that.

On Thu, Jun 2, 2016 at 11:50 AM Emanuel Berg <address@hidden> wrote:

> papab <address@hidden> writes:
>
> > I have a whole bunch of sequences of numbers,
> > like this: 5.1816, -3.81, 4.8768, 5.1816,
> > -4.4196, 4.8768, 6.4008, -4.4196, 5.48640,
> > 6.4008, -3.81, 5.486400;
> >
> > I'd like to be able to make it look like this
> > easily: 5.1816, -3.81, 4.8768, 5.1816,
> > -4.4196, 4.8768, 6.4008, -4.4196, 5.486400,
> > 6.4008, -3.81, 5.48640
> >
> > 3 numbers per row. Suggestions?
> > Some variation of fill-paragraph?
>
> You want to separate data, programming
> (modification of the data), and interface
> (display of the result).
>
> Here, there is no modification of the data, but
> you still want the display (interface) to be
> programmable, as sometime in the future perhaps
> you want four data items per row and then it'll
> be super-fast to change the digit 3 into a 4
> with no other change necessary!
>
> This is called MVC but what happens when people
> explain and/or define that is that everyone
> gets confused and irritated. But it is
> actually simple!
>
> So if you understood my description as I think
> you did, *don't* read the Wikipedia article on
> MVC! [1]
>
> I'd do:
>
>     1. Put the data in a text file with no
>        commas and one and only one data item
>        per line.
>
>     2. Write a defun that reads that into
>        a Lisp list.
>
>     3. Write a defun that iterates the list and
>        prints a newline for every X items, 3 in
>        your case.
>
> Tell me if you need help with any of those
> steps :)
>
> [1] Hey, I told you not to read it!
>
> --
> underground experts united .... http://user.it.uu.se/~embe8573
> Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
>                    - so far: 34 Blogomatic articles -
>
-- 

-- 
Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]