custom macro works when recorded, but not when run
Submitted by Sunday, 28 February, 2010 - 19:55
on
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
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