Er… I have never been using an outliner as an outliner, nor working with paragraph styles simulating the functionality of an application of that kind and I don’t understand well the discussions above. So it is very likely that I’m doing something pointless but perhaps macros in the zip archive below
might be of some interest for those who are using Geoff’s
Outline.dot or something similar.
One of the macros increases the level of numbered paragraph styles in continuous or non-continuous selections. For example, when you have a selection consisting of multiple paragraphs having various numbered paragraph styles in the following manner:
Heading 1
Body Entry 1
Heading 2
Body Entry 2
Body Entry 2
Heading 3
Body Entry 3
Heading 2
Body Entry 2
the macro will replace each of those styles with that of the next level so that you will get
Heading 2
Body Entry 2
Heading 3
Body Entry 3
Body Entry 3
Heading 4
Body Entry 4
Heading 3
Body Entry 3
Another macro does just the opposite: decrease the level of numbered paragraph styles in selection(s). The only difference between the two is that
$number += 1 in the former is
$number -= 1 in the latter.
Those two macros work for a single paragraph partially selected, too.
The third and last macro is the same as the one posted to the Macro forum as “Insert Newline and Apply Heading Style” macro:
http://nisus.com/forum/viewtopic.php?p=19017#p19017
except that I simplified the long and bad macro name into “Insert Heading” and added
$numberFirst option and some code for supporting style names such as
1 Heading,
2 Heading… when that option is set to
true.
Here is the code of the first macro.
Code: Select all
### Increase Numbered Paragraph Style Level ###
$numberFirst = false # true: for styles such as 1 Heading, 2 Heading...
$doc = Document.active
if $doc == undefined
exit
end
$findNumberedStyle = '^(?<baseName>.*[^0-9])(?<number>[0-9]+)$'
if $numberFirst == true
$findNumberedStyle = '^(?<number>[0-9]+)(?<baseName>[^0-9].*)$'
end
$sels = $doc.textSelections
$nameToStyle = Hash.new
foreach $style in $doc.paragraphStyles
if $nameToStyle{$style.name} == undefined
$nameToStyle{$style.name} = $style
end
end
foreach $sel in $sels
$paraStarts = Array.new # get paragraph start(s) in $sel
while $sel.range.bound > $sel.text.rangeOfParagraphAtIndex($sel.location).location
$paraStarts.appendValue $sel.text.rangeOfParagraphAtIndex($sel.location).location
if $sel.text.rangeOfParagraphAtIndex($sel.location).bound < $sel.bound
$sel = TextSelection.newWithLocationAndBound $sel.text, $sel.text.rangeOfParagraphAtIndex($sel.location).bound, $sel.bound
else
break
end
end
foreach $start in $paraStarts
$styleName = $sel.text.attributesAtIndex($start).paragraphStyleName
if $styleName.find $findNumberedStyle, 'E-i$'
$number += 1
if $numberFirst == true
$newStyleName = $number & $baseName
else
$newStyleName = $baseName & $number
end
if Defined $nameToStyle{$newStyleName}
$paraStart = TextSelection.newWithLocationAndLength $sel.text, $start, 0
Push Target Selection $paraStart
$nameToStyle{$newStyleName}.apply
Pop Target Selection
end
end
end
end
The macro above does nothing for inexistent paragraph styles. No error message. I mean, for example,
Heading 6 will remain
Heading 6 silently because
Heading 7 is not available in
Outline.dot’s style sheet if you are using it without modification. Error dialog is annoying for something obvious to one who is in front of the display monitor, especially that shown by a macro run accidentally (that happens often to me with macros having shortcuts).
I forgot to say that
Increase Numbered Paragraph Style Level and
Decrease Numbered Paragraph Style Level macros work with any paragraph styles whose names are:
BaseName 1,
BaseName 2 and so on
or, if
$numberFirst = true,
1 BaseName,
2 BaseName and so on. To use
Insert Heading macro for document files whose numbered Heading and Body Text paragraph style names are different from those defined in
Outline.dot, you have to customize
Code: Select all
$headingBaseName = 'Heading'
$bodyBaseName = 'Body Entry'
in the very beginning of the macro so that it understands those in your document files.
Some more explanation in the comment lines of the macro files.
% % % % % % % % % % % % % % % % % % % %
I do have OmniOutliner but I’m using it just for taking notes, not as an outliner. Making an outline before beginning to write a document is against my way. In the past, I tried to accustom myself to the outline-first-
ideology — yes, it is just an ideology among innumerable ideologies, why not? why don’t you rely on your native ability to structure your documents intuitively and capriciously??? — but
very, very soon I gave up
very, very happily ;-)
Anyway OO was the
first OS X application I purchased (or perhaps OmniWeb? — my physical memory is
exceptionally volatile in these days). When I began to run OS X (10.0.3), OO was the
only Cocoa application for manipulating text
AND enabling you to do some
regex find/replace. I tried to use it as a kind of word processor but it was not very handy for that purpose and OO’s regex ability was/is rather poor, to say the least. Now I’m running Nisus Writer Pro, a fully featured word processor with the excellent support of
regex (regular expression).
Like in a dream…