all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How can I customize this repetive edit?
@ 2004-01-22 20:36 exits funnel
  0 siblings, 0 replies; 5+ messages in thread
From: exits funnel @ 2004-01-22 20:36 UTC (permalink / raw)


Hello,

I have a text file which contains a coupld of hundred
lines which look like this:

>foo   EAL_FOO

I need them to look like this:

>  EAL_FOO="foo";

Note that '>' is not part of the line but included to
denote the beginning of the line (ie, the foo in the
first example is flush with the beginning of the line
while line in the second example starts with two
spaces.  Also note the EAL_ is fixed but foo can take
any value though the case of foo and FOO respectively
will always adhere to the pattern in the example.  

I really don't want to make all these changes by hand.
 I'm pretty new to EMACS but it seems this should be
doable (everything else is :) ).  If anyone could
point me in the right direction I'd really appreciate
it.

-exits

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can I customize this repetive edit?
       [not found] <mailman.1171.1074804795.928.help-gnu-emacs@gnu.org>
@ 2004-01-22 21:12 ` Chris McMahan
  2004-01-22 21:37   ` Johan Bockgård
  2004-01-22 22:49 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Chris McMahan @ 2004-01-22 21:12 UTC (permalink / raw)


Emacs macros would be good here. 

Just start recording a keyboard macro C-x (

Execute the keyboard commands to reformat your text

Stop the macro recording C-x )

Here's a BASIC macro that does what you want. 

(fset 'foo
   [?\C-  ?\M-f ?\C-w ?\C-e ?= ?\" ?\C-y ?\" ?\C-a ?\C-  ?\M-f ?\M-b ?\C-w ?\C-e ?\; ?\C-a ?\C-n])

Load this by placing your cursor after the closing ) above and typing C-x e

Then load your file, place the cursor on the first line of text, and
type M-x foo to execute the macro

- Chris


exits funnel <exitsfunnel@yahoo.com> writes:

> Hello,
> 
> I have a text file which contains a coupld of hundred
> lines which look like this:
> 
> >foo   EAL_FOO
> 
> I need them to look like this:
> 
> >  EAL_FOO="foo";
> 
> Note that '>' is not part of the line but included to
> denote the beginning of the line (ie, the foo in the
> first example is flush with the beginning of the line
> while line in the second example starts with two
> spaces.  Also note the EAL_ is fixed but foo can take
> any value though the case of foo and FOO respectively
> will always adhere to the pattern in the example.  
> 
> I really don't want to make all these changes by hand.
>  I'm pretty new to EMACS but it seems this should be
> doable (everything else is :) ).  If anyone could
> point me in the right direction I'd really appreciate
> it.
> 
> -exits
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
> 
> 

-- 
     (.   .)
  =ooO=(_)=Ooo========================
  Chris McMahan | cmcmahan-at-one.net
  ====================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can I customize this repetive edit?
  2004-01-22 21:12 ` Chris McMahan
@ 2004-01-22 21:37   ` Johan Bockgård
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Bockgård @ 2004-01-22 21:37 UTC (permalink / raw)


Chris McMahan <cmcmahan@thenumber1spelledout.net> writes:

>  [...] ?\C- ?\M-f ?\M-b ?\C-w [...]

`M-\' (`delete-horizontal-space')

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can I customize this repetive edit?
       [not found] <mailman.1171.1074804795.928.help-gnu-emacs@gnu.org>
  2004-01-22 21:12 ` Chris McMahan
@ 2004-01-22 22:49 ` Stefan Monnier
  2004-01-23 17:12   ` Jeff
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2004-01-22 22:49 UTC (permalink / raw)


> I have a text file which contains a couple of hundred
> lines which look like this:

> >foo   EAL_FOO

> I need them to look like this:

> >  EAL_FOO="foo";

M-x query-replace-regexp RET
^\([a-z]+\) +EAL_\([A-Z]+\) RET
  EAL_\2="\1"; RET


-- Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can I customize this repetive edit?
  2004-01-22 22:49 ` Stefan Monnier
@ 2004-01-23 17:12   ` Jeff
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff @ 2004-01-23 17:12 UTC (permalink / raw)


On Thu, 22 Jan 2004 22:49:44 +0000, Stefan Monnier wrote:

>> I have a text file which contains a couple of hundred
>> lines which look like this:
> 
>> >foo   EAL_FOO
> 
>> I need them to look like this:
> 
>> >  EAL_FOO="foo";
> 
> M-x query-replace-regexp RET
> ^\([a-z]+\) +EAL_\([A-Z]+\) RET
>   EAL_\2="\1"; RET
> 
> 
> -- Stefan

Stefan - that is really useful to know. Thanks. 

-Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-23 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-22 20:36 How can I customize this repetive edit? exits funnel
     [not found] <mailman.1171.1074804795.928.help-gnu-emacs@gnu.org>
2004-01-22 21:12 ` Chris McMahan
2004-01-22 21:37   ` Johan Bockgård
2004-01-22 22:49 ` Stefan Monnier
2004-01-23 17:12   ` Jeff

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.