From: <du...@sp...> - 2010-02-27 07:22:35
|
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 regu- lar 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. 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 ] [ beginning 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 |
From: Robert S. <Robert@Schwenn-R.de> - 2010-02-28 21:21:38
|
Maybe You've used the mouse while recording? Mouse clicks are not recorded. Else You could track down the problem to one or two lines by executing the macro step by step: Comment out most lines except a few leading ones, execute the macro, check the result. If it's ok, add a few lines more, and so on. Then maybe You're able to ask a concrete question... Robert |