Subject: bug#52265: Wishlist: Behavior of rectangles when last line is short

From: Tor Kringeland <[email-masked]>
Date: Sat, 04 Dec 2021 21:33:25 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Killing the region (i.e., using `C-w') works fine for me...

I should have been more clear.  I used `kill-rectangle' to kill the
region so that I can yank it as a column to the right of the three first
lines; this is done using `yank-rectangle' at the end of the first line,
after inserting a number of spaces.

> I think this is way outside the scope of rectangles.  Your use case
> seems to be to turn a series of lines into CSV columns -- but that's
> better expressed through a CSV command.  You might want to group them by
> two or three or four lines into columns, for instance.

I see your point, and my example is relevant for creating CSV records,
but I think what rectangles already bring are pretty close to the
desired end result.

The crux is turning a collection of lines into columns, which you can
already do by killing/yanking rectangles.  The behavior in the first
point would be nice in general, as having the killed rectangle extend to
the end of the lines instead of just being the length of the current
line, is a nice optional feature to have, I think, which extends beyond
my CSV example.

The behavior in the second point is more geared toward this specific
example, but it's also a general one.  Basically it's about allowing the
user to optionally specify what column separator to use.  The default
one is tabs and spaces for visual alignment.  In my CSV example a comma
would be used.  And you could /e.g./ use a vertical bar for `org-mode'
tables.

As a sidenote, `org-mode' already sidesteps this last issue by having
the command `org-table-create-or-convert-from-region' which can create a
table from the resulting columns after yanking the rectangle.  Maybe
something similar could be done in `csv-mode'?  It would solve the issue
wrt. my second point, though I still think there is some general use in
being able to specify the column separator.