Topic: Needs enhancement of Search & Replace (1 of 19), Read 152 times
Conf: Search and Replace
From: Peter Rejto
Date: Tuesday, July 29, 2003 07:03 PM

Hi,

I need an enhancement of the Search and Replace macro.
Specifically, I would like to replace the letter "j"
by the greek letter "rho" in my formulae and only in my
formulae. These formulae are embedded between the
"\begin{equation}" and "\end{equation}" markers.

I have a hunch that this is a very simple question.
Put a begin block marker at the first "\begin{equation}"
and an end of block marker at the corresponding equation}". Then apply the Search & Replace macro to this block. Then repeat it.

A similar problem would be to edit an .html file.
There I do not wish to edit my comments. So the replacements
should be outside the range marked by "(!--" and "-->"

I would like to have an enhanced Search & Replace command,
where I could add a "turn-off-flag" and a "turn-on-flag".
Then the command would act only if I am in the "turn-on-flag"
region.

Thanks,

-peter.

 


Topic: Needs enhancement of Search & Replace (2 of 19), Read 148 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Wednesday, July 30, 2003 05:24 PM

Peter:

Specifically, I would like to replace the letter "j"
> by the greek letter "rho" in my formulae and only in my
> formulae. These formulae are embedded between the
> "\begin{equation}" and "\end{equation}" markers.
>
> I have a hunch that this is a very simple question.

As you say, this is straightforward. Provided your equations consist of solid paragraphs (no blank lines inside, "\" not defined as para_sep), you could simply experiment with something like (untested):

while(!AT_EOF){
s("\begin{equation}",errbreak)
BB(CP)
RB("j","rho",CP,EOP_pos,noerr+all)
}

EOP_pos is "end of paragraph position".

If there are blank lines inside your equations you have to search for "\end{equations}", to set your block end marker there and then to RB("j","rho",BB,BE....).

Fritz

 


Topic: Needs enhancement of Search & Replace (3 of 19), Read 140 times
Conf: Search and Replace
From: Peter Rejto
Date: Friday, August 01, 2003 08:13 PM

On 7/30/2003 5:24:56 PM, Fritz Heberlein wrote:
>Peter:
>
> Provided your
>equations consist of solid
>paragraphs (no blank lines
>inside, "\" not defined as
>para_sep), you could simply
>experiment with something like
>(untested):
>
>while(!AT_EOF){
>s("\begin{equation}",errbreak)
>BB(CP)
>RB("j","rho",CP,EOP_pos,noerr+
>all)
>}
>
>EOP_pos is "end of paragraph
>position".
>
>If there are blank lines
>inside your equations you have
>to search for
>"\end{equations}", to set your
>block end marker there and
>then to
>RB("j","rho",BB,BE....).

Thanks Fritz,

I did some experiments and this is what I came up with:
The RB command, Replace_Block works provided that the cursor is within the marked block. Otherwise, I get a "j" not found message.

Looking forward to hearing from you.

-peter.

 


Topic: Needs enhancement of Search & Replace (4 of 19), Read 138 times
Conf: Search and Replace
From: Peter Rejto
Date: Saturday, August 02, 2003 01:54 AM

On 7/30/2003 5:24:56 PM, Fritz Heberlein wrote:
>
>while(!AT_EOF){
>s("\begin{equation}",errbreak)
>BB(CP)
>RB("j","rho",CP,EOP_pos,noerr+
>all)
>}
>
>EOP_pos is "end of paragraph
>position".
>
>If there are blank lines
>inside your equations you have
>to search for
>"\end{equations}", to set your
>block end marker there and
>then to
>RB("j","rho",BB,BE....).


Fritz,

Please ignore my previous answer.

I have specialized your suggestions to a single
Replace_Block command and also allowed error messages.
This is what I came up with:

Search("\begin{equation}",errbreak)
Block_Begin(Cur_Pos)
Search("\end{equation}",errbreak)
Block_End(Cur_Pos)
Replace_Block("j","rho",Block_Begin, Block_End,all)

I have a hunch that I am missing something simple.
In any case the macro does not work for me. However, the Replace_Block part does work. In other words, if I mark the block manually and then call the Replace_Block part of the macro, then it works.

The macro also marks properly the block that I need.

So, it seems that the macro does each of the halves of the task correctly. Never the less, when it comes to the task, I get a "no j found " message. So, I am at a loss.

-peter.

 


Topic: Needs enhancement of Search & Replace (5 of 19), Read 138 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Saturday, August 02, 2003 03:15 AM

Peter:

> I have a hunch that I am missing something simple.

You have to place the cursor at Block_Begin. Please try the following and tell me if it works for you:

while(!AT_EOF){
s("\begin{equation}",errbreak)
BB(CP)
s("\end{equation}",errbreak)
BE(CP)
GotoPos(BB)
RB("j","rho",BB,BE,noerr+all)
}

Fritz

 


Topic: Needs enhancement of Search & Replace (6 of 19), Read 137 times
Conf: Search and Replace
From: Peter Rejto
Date: Saturday, August 02, 2003 09:59 AM

On 8/2/2003 3:15:10 AM, Fritz Heberlein wrote:

> Please try the
>following and tell me if it
>works for you:
>
>while(!AT_EOF){
>s("\begin{equation}",errbreak)
>BB(CP)
>s("\end{equation}",errbreak)
>BE(CP)
>GotoPos(BB)
>RB("j","rho",BB,BE,noerr+all)
>}


Thanks Fritz,

I am still missing something. Here are the specifics:
If the cursor is before a \begin{equation} and \end{equation}
block then it works fine! Otherwise I get a
"waiting for disk or Ctrl-C message"
If I press enter then it highlights the relevant block.

In other words, it works for a single block, but not for all of the blocks.

-peter.

 


Topic: Needs enhancement of Search & Replace (7 of 19), Read 126 times
Conf: Search and Replace
From: Peter Rejto
Date: Saturday, August 02, 2003 03:55 PM

Fritz,

You really helped me out!
I made a slight adjustment, and now it works.
Specificaly, I added an extra line, which puts the cursor at the end of the block, before repeating the loop.
Here are the details:

// HR_S&R; Heberlein_Rejto Search and Replace macro.
// This is an adaptation of the Vedit Replace_Block // // macro command to the special case of a block defined // by the \begin{equation} and \end{equation}
// strings. The pair of replacement strings are also // // special!
while(!AT_EOF){
Search("\begin{equation}",errbreak)
Block_Begin(Cur_Pos)
Search("\end{equation}",errbreak+advance)
Block_End(Cur_Pos)
GotoPos(Block_Begin)
Replace_Block("j","rho",Block_Begin,Block_End,noerr+all)
Search("\end{equation}",errbreak+advance)
}

A nice feature of your macro is that a part of it can be used to highlight a block between the "\begin{equation}" and "\end{equation}" strings. If I specialize these strings to consist of a parenthesis character then I highlighted the block between matching parentheses. This is a configuration feature of the emacs linux editor and many of my colleagues consider it to be their favorite. So, I hope that Ted will also incorporate this feature into Vedit.

I also would like to do some more experiments. I have a hunch that the specific forms of the string defining the block is not relevant provided that there are no nested blocks. This is certainly the case for my original problem. On the other hand I would like to generalize it. So, I thought to replace the above strings by "begin{" and "\end{". Since everything is between "\begin{document}" and "\end{document}", there is some nesting. I hope to be able to report on this soon.

Thanks again,

-peter.

 


Topic: Needs enhancement of Search & Replace (8 of 19), Read 125 times
Conf: Search and Replace
From: Christian Ziemski
Date: Sunday, August 03, 2003 03:34 AM

Peter:

Perhaps the following could help you a bit:


SR_Set("j", "rho", SET)
Block_Begin(CLEAR)
while (!AT_EOF) {
Search("\begin|H7B", ERRBREAK+ADVANCE)
#103=Cur_Pos
Search("|H7D", ADVANCE)
Reg_Copy_Block(103, #103, Cur_Pos)
Block_Begin(Cur_Pos)
Search("\end|H7B|@(103)", ERRBREAK)
Block_End(Cur_Pos)
// the BEGIN option lets RB() do the whole block
Replace_Block("", "", Block_Begin, Block_End, BEGIN+ALL+NOERR)
Goto_Pos(Block_End)
Block_Begin(CLEAR)
}



Christian

 


Topic: Needs enhancement of Search & Replace (9 of 19), Read 123 times
Conf: Search and Replace
From: Peter Rejto
Date: Sunday, August 03, 2003 11:07 AM

On 8/3/2003 3:34:19 AM, Christian Ziemski wrote:

>Perhaps the following could
>help you a bit:
>
>
>SR_Set("j", "rho", SET)

Thanks Christian,

I have been thinking about your comments that you made in connection with your check parentheses macro. I was just not able to incorporate them.

Although the SR_Set command that you mentioned is new to me, it already helped me quite a bit. The replacement strings "j" and "\rho" are only typical examples. Now it is in the beginning of the macro, so I can easily edit them.

I also would like to make the Block Begin and Block End strings editable. Do you have a Dialog Box macro that I could adapt for this problem? (I know that you have sent me numerous tutorials on Dialog Boxes.)


Now I should work on your macro.

Thanks again,

-peter.

 


Topic: Needs enhancement of Search & Replace (10 of 19), Read 122 times
Conf: Search and Replace
From: Peter Rejto
Date: Sunday, August 03, 2003 01:46 PM

Christian,

After a slight, TeX specific adaptation your macro seems to work. Actually, I am amazed that it does work. After you replaced my Block_Begin string "\begin{equation}" by the more general one, "\begin{", my blocks became nested. Do I remember one of the morals of your comments about checking parentheses correctly: this problem is very easy if the parentheses are not nested and it is very difficult if they are nested?

So, I was lucky that my nested blocks were not too bad.

Since the entire macro is still short, I am attaching it:
---------------------------------------------------
// HRZ.VDM; Heberlein-Rejto-Ziemski Replace Block;
// Wildfile version of Vedit Replace_Block.


SR_Set("j", "\rho ", SET)

// rejto adaptation; place cursor after the "\begin{document}" tag.
Search("\begin{document}", ADVANCE)

Block_Begin(CLEAR)

while (!AT_EOF) {
Search("\begin|H7B", ERRBREAK+ADVANCE)
#103=Cur_Pos
Search("|H7D", ADVANCE)
Reg_Copy_Block(103, #103, Cur_Pos)
Block_Begin(Cur_Pos)
Search("\end|H7B|@(103)", ERRBREAK)
Block_End(Cur_Pos)
// the BEGIN option lets RB() do the whole block
Replace_Block("", "", Block_Begin, Block_End, BEGIN+ALL+NOERR)
Goto_Pos(Block_End)
Block_Begin(CLEAR)
}

---------------------------

Thanks again,

-peter.

 


Topic: Needs enhancement of Search & Replace (11 of 19), Read 124 times
Conf: Search and Replace
From: Pauli Lindgren
Date: Thursday, August 07, 2003 10:29 AM

On 8/2/2003 3:55:51 PM, Peter Rejto wrote:
>
>A nice feature of your macro is that a part of it can be
>used to highlight a block between the "\begin{equation}"
>and "\end{equation}" strings.
>If I specialize these strings to consist of a parenthesis
>character then I highlighted the block between matching
>parentheses. This is a configuration feature of the
>emacs linux editor and many of my colleagues consider it to
>be their favorite. So, I hope that Ted will also
>incorporate this feature into Vedit.

I have not needed to highlight a block between matching parenthesis except when editing C source. In this case, it is useful to be able to highlight a C block between { and }.

That is why I have included this function into key Alt-3 in my C.KEY keyboard file (which is included in my C-tools package):
http://koti.mbnet.fi/pkl/c_tools.htm#ckey

That is, if you have an if block such as


if (foo==bar)
{
...
}


you can put cursor anywhere in the if-line and press Alt-3, and the whole block is highlighted, including the if line. If you put the cursor at line containing "{", then the highlight starts from that line and the if line is not included.
This works with nested blocks, too.
The macro defined to the Alt-3 key is quite simple:

[VISUAL EXIT]BOL BB(CP) S("|123") MP EOL BE(CP) GP(BB)


--
Pauli

 


Topic: Needs enhancement of Search & Replace (12 of 19), Read 122 times
Conf: Search and Replace
From: Peter Rejto
Date: Friday, August 08, 2003 12:49 PM

Thanks Pauli,

For sharing yoour programs with me. I looked at your C_PAREN.VDM and I find your Statline_Message("") very nice!
It is certainly nice to be reassured that the macro does work.

However, running your macro, I did not see this message on my Status Line. Then I tried to isolate it. I copied it to the clipboard and then pressed {ESC, C}. Once in command mode I used Ctr-l V, but nothing appeared on my Status Line. Incidentally, I learned the usefulness of entering a command from the clipboard from one of your webboard messages.

At present I am fine tuning my macro. I tried to incorporate a Latex shortcut for the math environment. Specifically, the blocks marked by $$ and $$. So, I replaced each or the two previous markers by $$. It finds the block OK but does not do the replacements. I have a hunch that I am missing something very simple. So I thought to enclose it, hoping that somebody will look at it!

Thanks to all of you.
-peter.
------------------
SR_Set("j","\rho",SET)
// rejto adaptation; place cursor after the "\begin{document}" tag.
Search("\begin{document}", ADVANCE)

Block_Begin(CLEAR)

while (!AT_EOF) {
Search("\begin|H7B", ERRBREAK+ADVANCE)
#103=Cur_Pos
Search("|H7D", ADVANCE)
Reg_Copy_Block(103, #103, Cur_Pos)
Block_Begin(Cur_Pos)
Search("\end|H7B|@(103)", ERRBREAK)
Block_End(Cur_Pos)
// the BEGIN option lets RB() do the whole block
Replace_Block("", "", Block_Begin, Block_End, BEGIN+ALL+NOERR)
Goto_Pos(Block_End)
Block_Begin(CLEAR)
}

Begin_Of_File
// rejto adaptation; place cursor after the "\begin{document}" tag.
Search("\begin{document}", ADVANCE)

Block_Begin(CLEAR)

while (!AT_EOF) {
Search("$$", ERRBREAK+ADVANCE)
#103=Cur_Pos
Search("$$", ADVANCE)
Reg_Copy_Block(103, #103, Cur_Pos)
Block_Begin(Cur_Pos)
Search("$$@(103)", ERRBREAK)
Block_End(Cur_Pos)
// the BEGIN option lets RB() do the whole block
Replace_Block("", "", Block_Begin, Block_End, BEGIN+ALL+NOERR)
Goto_Pos(Block_End)
Block_Begin(CLEAR)
}

 


Topic: Needs enhancement of Search & Replace (13 of 19), Read 122 times
Conf: Search and Replace
From: Peter Rejto
Date: Saturday, August 09, 2003 12:42 PM

On 8/7/2003 10:29:09 AM, Pauli Lindgren wrote:

>[VISUAL EXIT]BOL BB(CP) S("|123") MP EOL
>BE(CP) GP(BB)


Thanks Pauli,

Since my last webboard message I have solved my technical TeX
problem. So, I am back to highlighting text between parentheses. I had some problems with the above macro of yours.

Here are the specifics. I have copied your message to my
to my windows clipboard. Then used Vedit to edit my Latex file. I put the cursor between two curly braces. Then I went into command mode, by pressing the {ESC, C} keys. Finally, I pressed the Ctrl-V key.

I have a hunch that I am missing something simple.

Thanks again,

-peter.

 


Topic: Needs enhancement of Search & Replace (14 of 19), Read 122 times
Conf: Search and Replace
From: Pauli Lindgren
Date: Tuesday, August 12, 2003 10:25 AM

On 8/9/2003 12:42:05 PM, Peter Rejto wrote:
>
>I have copied your message to my
>to my windows clipboard. Then used Vedit
>to edit my Latex file. I put the cursor
>between two curly braces. Then I went
>into command mode, by pressing the {ESC,
>C} keys. Finally, I pressed the Ctrl-V
>key.

The "Highlight C block" keyboard macro assumes that you put cursor BEFORE the first curly brace. Further, if you enter the macro from command line, you do not include the [VISUAL EXIT].

Anyway, here is a macro that highlights a block between any type of parenthesis ()[]{}<>. Here, you put cursor between the parenthesis and the macro searches backwards for first parenthesis of any type, then finds matching pair and highlights the block.
If you use it in keyboard definition, at the [VISUAL EXIT].

S("|P",REVERSE) BB(CP+1) MP BE(CP) GP(BB)

--
Pauli

 


Topic: Needs enhancement of Search & Replace (17 of 19), Read 122 times
Conf: Search and Replace
From: Peter Rejto
Date: Wednesday, August 13, 2003 02:35 AM

On 8/12/2003 10:25:14 AM, Pauli Lindgren wrote:

>Further, if you enter
>the macro from command line, you do not
>include the [VISUAL EXIT].

Thanks Pauli, I knew that I was missing something very simple.

>
>Anyway, here is a macro that highlights
>a block between any type of parenthesis
>()[]{}<>. Here, you put cursor between
>the parenthesis and the macro searches
>backwards for first parenthesis of any
>type, then finds matching pair and
>highlights the block.
>If you use it in keyboard definition, at
>the [VISUAL EXIT].
>
>S("|P",REVERSE) BB(CP+1) MP BE(CP)
>GP(BB)

Thanks Pauli,

I really appreciate it! So, your short macro imports a sophisticated feature from e-macs! This also shows that
Vedit is a rather sophisticated program! In fact, my various questions about enhancing the Search and Replace family of macros was aimed at importing features from my S&R program, which I used before Vedit. This S&R program was discovered by a Twin Cities user group and got high accolades. Since I am running Latex from a Vedit User Menu, it is nice for me that I can also do my various mathematical book-keeping chores i

Now let me ask a minor point: Since I am reading Vedit programs only occasionally, I have to expand the short version of the macros. Would be possible to use a macro for that purpose?

Thanks again,

-peter.

 


Topic: Re: Needs enhancement of Search & Replace (18 of 19), Read 122 times
Conf: Search and Replace
From: Christian Ziemski
Date: Wednesday, August 13, 2003 02:48 AM

You wrote:

>Now let me ask a minor point: Since I am reading Vedit programs only occas
ionally, I have to expand the short version of the macros. Would be possibl
e to use a macro for that purpose?

You can try the macro CMD-CONV.VDM distributed with VEDIT.

But pay attention: Cited from the macro:

// NOTE: This macro is not foolproof! Check all commands and strings for
// proper conversion.
//
// By Peter B. Freed, Data Base Management Systems, Inc. 09/12/95


It's worth a try... (Don't forget to make a backup of your macro!)

Christian

--
cityweb DSL start ab monatlich 3,49 Euro *** http://www.cityweb.de
/dsl ***
Sekundenschneller Seitenaufbau, Downloads, Videos und vieles meh
r. Mit
Cityweb-DSL wird der Blick auf die Uhr beim Surfen überflüssig
!

 


Topic: Re: Needs enhancement of Search & Replace (15 of 19), Read 118 times
Conf: Search and Replace
From: Ted Green
Date: Tuesday, August 12, 2003 11:22 AM

At 10:30 AM 8/7/2003, you wrote:

>That is why I have included this function into key Alt-3 in my C.KEY keyboard file (which is included in my C-tools package):
> http://koti.mbnet.fi/pkl/c_tools.htm#ckey

First of all, your Alt-3 macro is very clever!
I have added it to the key-mac.lib file.

I will examine your entire C-tools package soon and,with your permission, include it in the next version of VEDIT.

I am particularly interested in including a "smart indenting" function for C. I see that you have already worked on such a macro.

Ted.



Ted.
-------------------------------------------------------------------------
Ted Green (ted@...) Greenview Data, Inc.
Web: www.... PO Box 1586, Ann Arbor, MI 48106
Tel: (734) 996-1300 Fax: (734) 996-1308 VEDIT - Text/Data/Binary Editor
-------------------------------------------------------------------------
Spam problems? www.SpamStopsHere.com blocks 99% of spam for businesses.

 


Topic: Re: Needs enhancement of Search & Replace (16 of 19), Read 121 times, 2 File Attachments
Conf: Search and Replace
From: Ian Binnie
Date: Tuesday, August 12, 2003 09:11 PM

On 8/12/2003 11:22:12 AM, Ted Green wrote:
>At 10:30 AM 8/7/2003, you
>wrote:
>
>I am particularly interested
>in including a "smart
>indenting" function for C. I
>see that you have already
>worked on such a macro.

There are at least 2 styles for C programming ({ on same line or new line).

I assume that you are talking about a real time macro.
I have a reformatting macro which operates on a whole program. This is only my preferred style (and unfortunately gets confused with "{" or "}" in strings).

I had intended to use some of the above to improve this latter.

There is also a Vedit version.

 
FRMT_C(1).VDM (7KB)
 
FRMT_V(1).VDM (3KB)

 


Topic: Re: Needs enhancement of Search & Replace (19 of 19), Read 121 times
Conf: Search and Replace
From: Pauli Lindgren
Date: Monday, August 18, 2003 11:21 AM

On 8/12/2003 11:22:12 AM, Ted Green wrote:
>
>I will examine your entire C-tools package soon and,with
>your permission, include it in the next version of VEDIT.

I have not updated my web page for ages. The current version was uploaded before Vedit 6.0 was released. I have updated many of the macros etc. since then. The new version of web page is nearly ready, so I will try to upload it as soon as possible.

>
>I am particularly interested in including a "smart
>indenting" function for C. I see that you have already
>worked on such a macro.

The smart indent macro (C_indent.vdm) works quite well, and I have used it for years. (It is usually needed after you have copied a block that has incorrect indent level.)

The macro automatically indents a highlighted block based on the indent level of the first line of the block. If no block is highlighted, the cursor line is indented based on the previous line.

I have done some improvements since I last uploaded it to my web-page, but it still has some minor problems. For example, an if(...) line without curly braces is not indented, and switch...case is not indented quite as it should. But most of time, it is quite adequate.

--
Pauli