[comp.emacs] transpose, rotate, mirror of text ....

nieh@moose.steinmetz (nico nieh) (12/16/87)

I originated the following problems. Thanks for all kinds of responses.

>>1. Is there an easy way to transpose a matrix in GNU-Emacs ?
>>2. Is there an easy way to rotate a rectangular of text +90/-90 degrees ?
>>3. Is there an easy way to mirror a rectangular of text (vertical/horizontal) ?
>>4. How about reverse a line or reverse a region ?


In summary, I think the best way to do these problems is to write your own 
GNU Emacs Lisp programs. It should be very easy. Someone suggested
to use AWK or APL. I don't think it is a good idea since you have to write
AWK/APL program and run AWK/APL as a subprocess. Then you may want 
to cut it and to paste it to a proper position. It seems to me that writing
GNU Emacs Lisp code is much easier than writing AWK code.

My algorithm to solve these problems is

1.  use copy-rectangle-to-register      ---   say register n
2.  (setq tmp (get-register ?n))
3.  write your own lisp code to rotate or to transpose or to mirror or ....
    whatever over variable, tmp. This kind of Lisp code should be very short.
4.  (set-register ?n tmp)
5.  use insert-register to put the value of a register to anywhere.

The user interface may be similar to the rectangle package.
For example   M-x transpose       -- specify two corners
              M-x rotate-+90      -- specify two corners
              M-x rotate--90      -- specify two corners
     
--



Ko-Haw Nieh
General Electric Company               | ARPA: nieh@ge-crd.arpa            
Corporate Research and Development     | UUCP: nieh@moose.steinmetz.ge.com 
P.O BOX 8, 37-2001		       | UUCP: {uunet!}steinmetz!nieh!crd  
Schenectady, NY 12301		       | 518-387-7431