emacs_macro_example

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Newsgroups: comp.emacs
From: doom@kzsu.stanford.edu
Subject: Re: Picture Mode Question

Timothy Goldfield <T.Goldfield@ftel.co.uk> writes:

>I currently run xemacs in CPerl mode but have binded some of the picture
>minor modes to the arrow keys. I have added (picture-move-down) to the
>down key, (picture-move-up) to the up key etc etc.. I have done this
>because I find it easier to scroll around the page without the cursor
>jumping between columns. I also have delete key deletes forward assigned
>to the delete key. My questions is this:

>The problem with all these minor modes is they add white space
>characters to the ends of lines. If you then want to delete a line using
>the delete key you have to delete all the white space characters afetr
>the program code. If you've been jumping around the code there could be
>many of them and deleteing multiple lines. Is there something I could do
>or install that when deleting forward once you get to a stage where the
>only characters on the line are whitespace it deletes them all in one
>action?

I think other folks have pointed you at some solutions that
do what your asking for automatically. 

I just thought I'd give you some hints about using some 
of the manual features built into Gnu emacs (and I presume
xemacs): 

C-k     deletes eveything to the end of the line
M-SPC   collapses a block of spaces to a single space 
        (or inserts a single space, if there were none). 
C-e     skip to end of line

When I have a problem like you describe here, I tend to just
write a keystroke macro to clear it up. 

C-x (   start recording macro
C-e     skip to the end of the line
M-SPC   changes whitespace to a single space
C-b     skip back one 
C-d     delete the one space to the right
C-n     skip down one line
C-x )   finish recording macro.

M-<     skip to top of buffer
C-x e   run the macro once to test it 
C-u C-u C-u C-u C-x e     run the macro a hell of a lot.
                          (repeat as necessary). 

If the macro has inserted a lot of blank lines at the end of
the file, do this:

C-x o  collapses a block of blank lines into one. 

This probably seems like an excessive amount of work to have
to do, but once you get used to it, you tend to do all sorts
of minor jobs using slight variations of these techniques. 

Admittedly, you'll save yourself some work if you can find 
an existing fix to install (e.g. whitespace.el). 




the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu