[gnu.emacs] List and edit lines containing certain strings ?

jiang@bohr.rice.edu (Jun Jiang) (02/28/90)

I am wondering how hard it will be to let gnu-emacs do the following:

1). Upon request, list all lines (and only these lines) which contain
a certain string in the current buffer.  For example, list those lines
containing ``real*8'' in a FORTRAN program.

2). Edit these lines in the new buffer.  For example, change some of
the ``real*8'' to ``real*4''.

3). When the changes are done, exit the new buffer and return to the
original one.  Of course, the changes should not be lost. 

The reason I ask for this is that I have used an editor which has this
feature.  It was really nice because you can clearly see the changes
you made to the file.

nhess@dvlseq.oracle.com (Nate Hess) (02/28/90)

In article <JIANG.90Feb27134413@bohr.rice.edu>, jiang@bohr (Jun Jiang) writes:
>I am wondering how hard it will be to let gnu-emacs do the following:

>1). Upon request, list all lines (and only these lines) which contain
>a certain string in the current buffer.  For example, list those lines
>containing ``real*8'' in a FORTRAN program.

You can do this using `M-x occur', and another window will pop up
containing all lines with the string you specified.

>2). Edit these lines in the new buffer.  For example, change some of
>the ``real*8'' to ``real*4''.

>3). When the changes are done, exit the new buffer and return to the
>original one.  Of course, the changes should not be lost. 

Steps 2 and 3 you can't do directly with off-the-shelf Emacs, but you
can get something close with `M-%', which is query-replace.

You might try getting help on both of these commands to see if together
they do what you want.  (`C-h f' for help)

--woodstock
-- 
	   "What I like is when you're looking and thinking and looking
	   and thinking...and suddenly you wake up."   - Hobbes

nhess@oracle.com or ...!uunet!oracle!nhess or (415) 598-3046

raymond@rosarita.berkeley.edu (Raymond Chen) (03/01/90)

Has nobody yet thought of commandeering Outline-Mode to do this?

	M-x outline-mode
	M-x set-variable outline-regexp ".*real\*8"
	M-x hide-body
	 [edit to your heart's content]
	M-x show-all