Page 1 of 1

Selecting Next Sentence Backwards?

Posted: 2010-01-31 08:33:06
by bjast
In the case of following sentences:

"Now is the time for this work. Now is the time for this work. Now is the time for this work. Now is the time for this work."

Using the Select Sentence macro with the cursor in front of the first "Now", the entire next sentence is selected.

Moving the cursor between the end of the first sentence and the word "Now" of the second sentence, the macro selects both the first and the second sentences.

Moving he cursor between the end of the second sentence, and the word "Now" of the third sentence, the macro selects the second sentence instead of the third sentences.

Am I missing something, or is this macro buggy?

Re: Selecting Next Sentence Backwards?

Posted: 2010-01-31 20:28:02
by Kino
In NWP 1.3 and later, you’d better use the menu command :Edit:Select:Select Sentence (which takes account of abbreviations) to select the current or the next sentence. As to selecting the previous sentence, something like this will do the job.

Code: Select all

$selSentence = ':Edit:Select:Select Sentence'
$sel = TextSelection.active
Menu $selSentence
Select Start
if Find Previous '\S+', 'E-W'
	Menu $selSentence
else  # restore the selection
	TextSelection.setActiveRange $sel
end

Re: Selecting Next Sentence Backwards?

Posted: 2010-02-01 14:59:02
by martin
Kino's suggestions are good ones, the menu Edit > Select > Select Sentence should behave much more reliably. His macro is also better than our old macro; I'll see about updating our macro repository to take advantage of the new menu.