Bookmarking through macros

Get help using and writing Nisus Writer Pro macros.
Post Reply
js
Posts: 229
Joined: 2007-04-12 14:59:36

Bookmarking through macros

Post by js » 2007-06-15 00:58:00

I am still wondering, in beta 2, that you cannot bookmark the insertion point.

Within a macro you often want to start some process from the insertion point and afterwards get back there. You could do this with the bookmark function, like

Code: Select all

Bookmark as "myStart"
... actual macro
Select bookmark "myStart"
Remove Bookmark
This does not properly work under 3 conditions:
1) if the starting point is just the insertion point rather than an actual selection
2) starting with an non-contiguous selection
3) if the selection is within a text that is already bookmarked. (In spite of giving a clear unambiguous instruction which bookmark you want to delete, you are asked by the program which one it should be: the inner or the outer. I think this is less than perfect.

As to 1) I don't get the Nisus point of view either. What is so difficult to make a selection zero characters wide.
And as to 2) If non-contiguous selections cannot be handled why not consider the first chunk only in this case.
I tried to handle these problems with the new additions to beta 2, (selection insertion and selection length) and it works, but this is unexpectedly slower than with bookmarks.

A last point on the same subject: I think it would be extremely helpful if giving a new bookmark the name of an old bookmark would replace the old by the new. Lets say I work in a long document and I arrive at a point which I bookmark as "I_am_here_now", then a macro doing this could be applied along with the progress of the work.

User avatar
martin
Official Nisus Person
Posts: 4261
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Bookmarking through macros

Post by martin » 2007-06-15 12:57:38

js wrote:This does not properly work under 3 conditions:
1) if the starting point is just the insertion point rather than an actual selection
Correct, you cannot have an empty bookmark (eg: zero characters). Honestly I don't see any situation where adding, selecting, and finally removing a bookmark would be faster than the following:

Code: Select all

$selStart = Selection Location
$selLength = Selection Length
# do whatever
Set Selection $selStart, $selLength
Bookmarks are much heavier than a few selection reads/writes.
3) if the selection is within a text that is already bookmarked. (In spite of giving a clear unambiguous instruction which bookmark you want to delete, you are asked by the program which one it should be: the inner or the outer. I think this is less than perfect.
I will file a feature request that the Remove Bookmark command accept a parameter that specifies the bookmark name.

mountainman
Posts: 161
Joined: 2007-01-17 04:01:44

Post by mountainman » 2007-07-04 22:11:48

I too noticed that you cannot bookmark an insertion point (Nisus Writer Classic could do this). I wanted a macro to use when editing long files. What happens is that frequently I think of something I should check the whole file for, and stop editing to do it. But in a long file it's not easy to find your way back to where you were. So I wrote a macro to do this. Maybe all or part of this will be useful for others, so I'll post it here.

$exists = Select Bookmark “Goback”
if $exists == 0
Find “.”, “Er”
Bookmark As “Goback”
else
Remove Bookmark
Select End
end

This looks for a bookmark called Goback. If not found, it sets a bookmark (I chose the previous character arbitrarily). If found, it deletes the bookmark, and you end up with the cursor back at the original location.

Derick
Posts: 105
Joined: 2007-05-21 08:33:59

Post by Derick » 2007-07-10 19:08:23

I've set up a pair of macros to emulate the Quickmark behavior in WordPerfect (previously discussed here: http://www.nisus.com/forum/viewtopic.php?t=2387)

1) Set Quickmark -- consisting of the following two lines:

Find “.”, “Er”
Bookmark As “Quickmark"

2) Goto Quickmark -- consisting of the following two lines:

Select Bookmark “Quickmark”
Scroll to Selection

After trying mountainman's single / toggle macro, I decided I was more comfortable with separate Set and Goto macros.

Post Reply