Thanks Adrian and Mark for the additional refinements and discussion!
That’s good, Martin, except that it only works for Lists
That's true, and it's certainly a limitation that prevents using the macro more generally without list styles. Though if people are working exclusively with list styles, then not requiring the user to select the target paragraphs can be a great convenience. Whenever possible I prefer to keep my hands on the keyboard. This macro allows for such usage, eg: use a keyboard shortcut to activate it, instead of grabbing the mouse to select the paragraphs.
padding could be set at run-time rather than being a given amount (12pt) coded in the macro?
For Adrian's interactive macro how about we reduce the two prompts into one? As a user I always prefer fewer interruptions. We can get both values from the user via a single alert if we ask the user to place a comma between the before/after spacing amounts. Something like:
Code: Select all
$padding = Prompt Input ...
$padding.find( @String[(?<before>\d+\.?\d*)\s*,\s*(?<after>\d+\.?\d*)], 'E¢' )
That uses named regex captures and Nisus Writer's ¢ option to automatically convert the matched spacing numbers into variables.
Remixing the last few macros is of course possible. It's easy enough to create a macro that automatically selects the current list paragraphs, rather than requiring the user to select them upfront. I actually think it's not too hard to determine the user's intent from the initial selection. If the user has the selection (or insertion point) in a single paragraph with a list style applied, then probably the user wants the macro to automatically work on all proximate list paragraphs; on the other hand if there's a selection encompassing multiple paragraphs then probably the macro should operate strictly just on those selected paragraphs.
Here's a macro that takes all this into account and is hopefully One Macro to Rule Them All, at least for this task.