emacs-devel
[Top][All Lists]
Advanced

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

rectangle operations - narrowing?


From: Drew Adams
Subject: rectangle operations - narrowing?
Date: Sat, 8 Jul 2006 11:34:22 -0700

I was thinking of perhaps doing some stuff on rectangular areas of text
(e.g. columns of text) - in particular, searching over them, and I'd like to
know what, if anything already exists for this, before I start trying to
roll my own. I looked at the Emacs manual Rectangles stuff and library
rect.el, but I didn't notice what I'm looking for.

I also looked briefly in ses.el and went through the SES Info manual. SES
lets you do things like insert and delete columns and cut and paste
rectangular areas, but I didn't see what I'm looking for there either.

What I'd like to do, to start with, is, in effect, "narrow" to a region that
has the content of a given rectangle of text. The idea would be to operate
on this region in some way, and then widen again - in effect putting the
(possibly modified) rectangle back in context. Any modifications could be
considered to be limited to the rectangle boundaries, so, for example, any
insertion of text would make text overflow out of the rectangle at the right
(and be lost).

I mostly want to do things with the rectangle that don't modify the text. A
good example would be to search over text within a rectangle (only). The
search might, in effect, need to "narrow" to the rectangle and then "widen"
afterward, but the user might not see any narrowing. An isearch that is
limited to a rectangle could be useful in some contexts.

Think of tabular data, such as Dired, and searching within only a certain
column of text. Likewise query-replace and other operations. (This wouldn't
be very useful for Dired itself, because the columns have such dissimilar
data - regular search is fine. But some tabular data has similar data in
different columns, and it can useful to restrict the search.)

I could, I guess, use extract-rectangle to grab a rectangle's strings, put
those in another, empty buffer, operate on the text there (simulating
"narrowing"), and then track back to the original buffer. Or, for
modification, I could use kill-rectangle, change the rectangle (e.g. apply
an overlay, for searching), then yank-rectangle. Alternatively, some things
could be done via apply-on-rectangle, and even sort(-regexp)-fields, but I
don't think they would help with, say, isearch over a rectangle.

I was hoping there would already exist some analogous functions, for
rectangles, to `narrow-to-region', `widen', and `save-restriction', but I
guess not.

How would you approach this - any ideas or pointers? Thx.





reply via email to

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