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

Zmacs question



    Date: Wed, 7 Feb 90 12:50 EST
    From: attila@flash.bellcore.com (Leslie A. Walko)
    ...

    How can I CHOP OFF COLUMS of text on the left side to the screen?

If the columns all begin with ;'s, you can use c-Minus c-X c-;
c-X c-; with no argument will add a column of semicolons, 
and with an argument it will remove a column of semicolons.
To remove more than one column of semicolons, use it more than
once in a row.  Note that it operates on the region, you'll need
to re-establish the region between calls. e.g.,

;;foo
;;bar
;;baz

can be changed to just

foo
bar
baz

by putting the region around it and doing

 c-Minus c-X c-; c-X c-X c-Minus c-X c-;

where c-X c-X does re-establishes the pre-existing region as a side
effect of its normal action of exchanging point and mark.

If you want to remove a column of some other kind, you need to resort
to a keyboard macro.  A keyboard macro definition is begun by pressing

 c-X (

Once begun (you'll see an indication of the `macro level' in your status
line confirming that it is recording), you can type commands that you'll
want to repeat and then press 

 c-X )

to terminate recording.  You can invoke the macro you've defined by 
pressing
 c-X E
This facility is very general and can do much more than what you're asking
for.  Consider the case of wanting to take this output from Show Directory,
and to trim off both the first few columns and the trailing ones:

      mail.directory.1    1   DIRECTORY !   12/28/89 15:32:22 X=02/05/90  File-Server
D     mail.kbin.1093  401 1010404(16)      02/02/90 18:48:04 (02/02/90)
D     mail.kbin.1094  358 900901(16)       02/05/90 11:47:37 (02/05/90)
      mail.kbin.1095  358 900063(16)       02/05/90 17:51:53 (02/05/90)
      mail.kbin.1096  453 1139897(16)      02/06/90 18:02:37 (02/06/90)
      mail.kbin.1097  390 981525(16)   !   02/07/90 12:16:44 (02/07/90)

You could put the cursor at the beginning of the line marked mail.directory.1
and press

 c-X ( c-Space c-6 c-F c-W c-m-F c-K c-N c-A c-X )

Having done this, you can press c-X E to do the next line.  Press c-U c-X E
to do the remaining four lines.

Note that a common error in keyboard macros is to do the c-X ) before lining
yourself up for the next command.  e.g., before doing the c-N c-A.  If you
fail to do these last two commands, you find that you have a macro that wants
to start at the beginning of a line but that leaves you positioned at the end
of a line when it's done.  Such a macro does not generally work well with an
argument because its preconditions cannot be met.  What you want is a macro
definition that after executing once will leave you positioned in a way that
it can be immediately executed again.  (Think of the macro you're defining as
a prototypical iteration in a loop which is invoked N times by giving c-X E an
argument of N.)

Note also that you can use c-X Q in conjunction with c-X ( ... c-X ) in order
to get something Query Replace style.  c-X Q does nothing when a macro is defined,
but it will will pause and ask for Space/Rubout as Query Replace does when the
macro is executed.  If you respond Space, it will do the rest of the macro.
If you respond Rubout, it will skip the rest of the macro.  If you have invoked
the macro with an argument, the amount skipped is only the rest of one iteration.
So, for example, using the same text from above, you could have written:

 c-X ( c-Space c-6 c-F c-W c-m-F c-K c-N c-A c-X Q c-P c-Space c-N c-X c-U c-X )

to conditionally uppercase each line as it was processed.  In this case,
if you typed c-5 c-X E after executing the first line and then answered
Space Space Rubout Rubout Space, you would see:

MAIL.DIRECTORY.1
MAIL.KBIN.1093
MAIL.KBIN.1094
mail.kbin.1095
mail.kbin.1096
MAIL.KBIN.1097

You can type other things besides Space and Rubout to the c-X Q query,
but I won't go into that here.  I hope that's enough to get you going.

Note:
If you're going to try any of the stuff in this message, I recommend
that you hardcopy this message and then have the hardcopy available
for reference while you try the suggestions in a scrap Zmacs buffer
so that you don't have to destroy your sense of context in order to
refer back to what this message.  If you want a copy of this message
in the Zmacs buffer while you're working, you can do 
 m-X Kill Ring Save Message
in Zmail to save a copy of the message on the kill ring and then
you can go to Zmacs and do c-Y in the scrap buffer to yank it back
into the temp buffer.  But I recommend that you have hardcopy available
in addition, since it's pretty easy to destroy this message if you make
a mistake with the keyboard macros--they can take a little practice
to get used to using effectively.

Good luck.