jEdit Community - Resources for users of the jEdit Text Editor
custom macro works when recorded, but not when run
Submitted by dushanm on Sunday, 28 February, 2010 - 19:55
This was posted to jEdit-users but I never saw it show up, so is being re-
submitted it here.

I'm using jEdit 4.3.1 under Mac OS X.6.2 (Snow Leopard).

I recorded a macro to reformat a paragraph differently from how the re-
gular Format macro does it. This 'Reformat' macro is supposed to reformat
only from the line containing the cursor, put two spaces (instead of one)
after the sentence-end punctuation, and finally place itself at the be-
ginning of the next paragraph.

When recorded, it does exactly this, but when run as a macro it doesn't.

Here's what happens. Suppose I have 3 paragraphs, 1, 2, and 3, and the
cursor is somewhere in para 1. Then Reformat

- separates sentences in the region between the cursor and the end of
para 1 with two spaces,

- joins para 1 and para 2 by deleting the empty line separating them
(but without reformatting para 2), and

- if the cursor was on the 1st line of para 1, it moves it to the begin-
ning of that line; if the cursor is below the 1st line of para 1, it
places it at the beginning of para 3.

Here is the macro:

textArea.goToStartOfLine(false);
textArea.insertEnterAndIndent();
textArea.goToNextParagraph(true);
textArea.goToPrevLine(true);
SearchAndReplace.setSearchString(". ");
SearchAndReplace.setReplaceString(".. ");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(false);
SearchAndReplace.setRegexp(false);
SearchAndReplace.replace(view);
SearchAndReplace.setSearchString("? ");
SearchAndReplace.setReplaceString("?? ");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(false);
SearchAndReplace.setRegexp(false);
SearchAndReplace.replace(view);
textArea.formatParagraph();
textArea.goToPrevParagraph(false);
textArea.goToNextParagraph(false);
textArea.goToNextParagraph(true);
textArea.goToPrevLine(true);
SearchAndReplace.setSearchString("?? ");
SearchAndReplace.setReplaceString("? ");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(false);
SearchAndReplace.setRegexp(false);
SearchAndReplace.replace(view);
SearchAndReplace.setSearchString(".. ");
SearchAndReplace.setReplaceString(". ");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(false);
SearchAndReplace.setRegexp(false);
SearchAndReplace.replace(view);
textArea.goToPrevParagraph(false);
textArea.goToNextParagraph(false);
textArea.backspace();
textArea.goToNextParagraph(false);

Any suggestions as to why the altered behavior? Thanks.

- Dushan Mitrovich
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Mailing List
by Robert Schwenn on Mon, 01/03/2010 - 20:17
Your post is on the Mailing List and I answered there. So, chances are, that You get more input than here.

Robert
 
Mailing List
by Robert Schwenn on Tue, 09/03/2010 - 18:21
Hi Dushan,

Your mails to the jEdit User's Mailing List are there. Maybe You should try to change Your Mailing List settings to not get the mails "batched in a daily digest". Usually I get them instantly.

Also, could it be that these mails are moved to a SPAM folder in Your mail program or at Your provider ...?

Robert
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82348
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18495
BBEdit scheme   1.0   18116
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293