Save vs Apple versioning (?) problem

Get help using and writing Nisus Writer Pro macros.
credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Save vs Apple versioning (?) problem

Post by credneb » 2015-03-18 07:34:57

Numerous macros for adding to glossary files end with Save, leaving the window open.
Sometimes I will further edit the entries, but most often simply type cmd-W immediately to then close the window *without making any further changes.*
pre-2.1 this worked fine.

With v2.1, however, an irritating dialog pops up asking if I want to save the changes before closing or revert. As noted above, the changes have already been saved. There no changes to save. Clicking Save does something, but the system beep I have set to sound when Nisus saves a file does not beep. The window simply closes. Clicking Revert closes the window but does not reverse any changes because they were already saved by the macro.

Whether a bug or a feature, how can I make this superfluous dialog box not appear?

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

Re: Save vs Apple versioning (?) problem

Post by martin » 2015-03-18 14:55:01

I don't know why that dialog is appearing. Now that Nisus Writer Pro adopts OSX document versioning, all changes should be saved to open documents without interruption.

I tried to trigger the problem you describe with a simple macro:

Code: Select all

Select Document End
Insert Text "\nAppended."
Save
If I run that on any of a variety of open documents, I am not met with any kind of dialog when I close the document window. Is there anything unusual about your documents or your macros?

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-19 09:08:39

Perhaps the only thing special about the documents is they are glossary files (ngloss) in the Glossaries folder.
The macros call a separate macro to open the glossary to edit, then does a bit of text manipulation, and then ends with

Select All
Select End
Type Text $pasteText
Glossary Entry Break

Save

At this point there's a beep (indicating to me that the file was saved) and the glossary file is still open. typing cmd-W at this point gets the save prompt (the same one you get when closing a file with changes that have not been saved).

Perhaps because it's a ngloss file? Shouldn't think that would matter, but...

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-19 09:32:03

I just noticed that after the Save beep, " - Edited" is quickly appended to the filename at the top of the document window grayed out.

Save is the last statement in the macro. The file is definitely saved.

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-19 11:27:43

Should also note that the grayed-out "- Edited" does not appear when other macros that Save a non-glossary (rtf) document end. This only happens with glossary files.

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-19 11:59:37

Further observation suggests there is a timing problem.

If I key cmd-W quickly enough after hearing the beep, the file closes silently before "- Edited" has a chance to appear. No prompt to save changes.

If I wait a second or so, Edited appears, resulting in the described problem.

So something that should or should not happen seems to happen in this brief period btw Save executing and control returning to the open (glossary) document.

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

Re: Save vs Apple versioning (?) problem

Post by martin » 2015-03-19 21:06:45

Thanks for the additional information, but I still haven't been able to reproduce the problem. Here's what I tried:

1. I opened an existing glossary file of mine.
2. I ran a slightly modified version of the macro snippet you shared:

Code: Select all

$pasteText = “Hello!”
Select All
Select End
Type Text $pasteText
Glossary Entry Break
Save
3. The glossary document was modified and "— Edited" show in the document titlebar.
4. I closed the document, but no confirmation dialog appeared.

The appearance of "— Edited" is strange, and seems like a bug, since your macro instructs the document to be saved. I'll look into that. But I still don't know why you're seeing the prompt to confirm or discard your changes.

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-20 07:57:36

Thank you for confirming that you also get the -Edited appearing.

I tried your test, and still get the prompt to save the already-saved changes.

Curiouser and curiouser...

Don't know if it matters, but am running osx 10.9.5 on a Macbook Pro.

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

Re: Save vs Apple versioning (?) problem

Post by martin » 2015-03-20 14:56:35

Ah, I may have found the cause: in your system preferences, in the General area, there exists an option "Ask to keep changes when closing documents". It seems that if this option is checkmarked, I can reproduce the behavior you are seeing.

Which behavior is correct is a little bit confusing here:
1. Since your macro's final command is "Save", you should never be prompted when closing the document after the macro finishes. That's a bug.
2. Assuming your macro did not include any "Save" commands, the prompt to keep or discard changes is correct, since this system option is checkmarked.
3. If this system option is checkmarked it should apply to all documents in NWP, not just glossaries. We'll have to investigate the difference in behavior.

I hope that helps for now. Thank you for bringing this to our attention.

adryan
Posts: 201
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Save vs Apple versioning (?) problem

Post by adryan » 2015-03-22 18:35:42

G’day, all

More on the subject of the grey " — Edited" suffix in the Toolbar….

I have an AppleScript script that:–

(1) gets data from a Mail message
(2) uses the Finder to open an RTF destination file (which opens in Nisus Writer Pro); it contains the dummy text “XXXX” followed by a paragraph return
(3) gets Nisus Writer Pro to create a temporary workfile
(4) manipulates the Mail message data in the workfile via a NWP macro called by a Do Menu Macro command; this macro does not make any calls to AppleScript
(5) copies the contents of the workfile to the Clipboard
(6) closes the workfile without saving it.

The NWP macro runs with no problem. The whole AppleScript script runs with no problem.
This whole process leaves me with an open NWP document to which I now wish to append the contents of the Clipboard, separating them from any existing document text with two paragraph returns.

OK, so now I have a simple Nisus macro ("My_macro"):–

Select Document End
Type Newline
Type Newline
Paste
# If this was the first message in the document, remove the initial dummy text
Find and Replace @Text<XXXX\n\n\n>, "", 'Ea’
Save

Consider some scenarios:–

(A) If this Nisus macro is called by a Do Menu Macro command as the final command in the aforementioned AppleScript script, Nisus Writer Pro hangs indefinitely with the spinning beach ball, necessitating Force Quit.
(B) Now comment-out the Save command in the macro and run the AppleScript script which again calls the macro by a Do Menu Macro command. Now Nisus Writer Pro does not hang, but the Statusbar says: Running macro "My_macro". Filename at top of Toolbar has grey " — Edited" suffix appended. This situation persists indefinitely.
(C) Next, forget about the AppleScript script, ensure there is something in the Clipboard and run the macro directly on a simple Nisus document. Everything works as it should, with the grey " — Edited" suffix visible. The suffix automatically disappears after about 15 seconds.
(D) Finally, reinstate the Save command in the Nisus macro, ensure there is something in the Clipboard and again run the macro directly on a simple Nisus document. Everything works as it should, with the grey " — Edited" suffix appearing briefly, then disappearing. However, the grey " — Edited" suffix immediately reappears and then takes about 15 seconds to disappear finally.

To my mind, only Scenario C is without problem, assuming its 15-second delay is a properly functioning part of some autosave process.
BTW In System Preferences > General, "Ask to keep changes when closing documents" is unchecked.

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Sierra 10.12.6
Nisus Writer user since 1996

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-23 07:40:31

[quote]"Ask to keep changes when closing documents"[/quote]

Aha. Un/checking this option reproduces the behavior you describe. Note regular rtf documents affected by macros that end in Save are _not_ similarly affected. Only glossaries.

While you search for the solution, perhaps part of the problem is some timing issue as I previously wrote about, i.e., typing cmd-W quickly enough after the macro Save executes does not get the save/revert prompt.

Thanks for your help tracking this down. Until a solution comes along, I guess I will live with the prompt.

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

Re: Save vs Apple versioning (?) problem

Post by martin » 2015-03-25 17:42:17

Hello Adrian,
adryan wrote:(A) If this Nisus macro is called by a Do Menu Macro command as the final command in the aforementioned AppleScript script, Nisus Writer Pro hangs indefinitely with the spinning beach ball, necessitating Force Quit.
(B) Now comment-out the Save command in the macro and run the AppleScript script which again calls the macro by a Do Menu Macro command. Now Nisus Writer Pro does not hang, but the Statusbar says: Running macro "My_macro". Filename at top of Toolbar has grey " — Edited" suffix appended. This situation persists indefinitely.
These scenarios are particularly bad. Could you share your AppleScript with me for testing? You could attach it here on the forum, or send it to me privately via the menu Help > Send Feedback. Thanks!
(C) Next, forget about the AppleScript script, ensure there is something in the Clipboard and run the macro directly on a simple Nisus document. Everything works as it should, with the grey " — Edited" suffix visible. The suffix automatically disappears after about 15 seconds.
(D) Finally, reinstate the Save command in the Nisus macro, ensure there is something in the Clipboard and again run the macro directly on a simple Nisus document. Everything works as it should, with the grey " — Edited" suffix appearing briefly, then disappearing. However, the grey " — Edited" suffix immediately reappears and then takes about 15 seconds to disappear finally.
I'll also have to check these scenarios. It may just be that the "— Edited" suffix is lingering longer than it should, or could indicate a problem with the macro Save command.

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

Re: Save vs Apple versioning (?) problem

Post by martin » 2015-03-27 12:06:20

We have a new Pro 2.1.1 beta 2 that should fix these AppleScript issues.

credneb: the new beta should also fix the problems you had with the Save command not fully clearing the document's edited state.

adryan
Posts: 201
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Save vs Apple versioning (?) problem

Post by adryan » 2015-03-28 00:54:39

G’day, Martin et al

NWP 2.1.1 beta 2 does indeed fix the issues I had with AppleScript's calling (via “Do Menu Macro” commands) Nisus macros that include paragraph spacing and a Save command.

Thanks, Martin.

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Sierra 10.12.6
Nisus Writer user since 1996

credneb
Posts: 156
Joined: 2007-03-28 07:30:34

Re: Save vs Apple versioning (?) problem

Post by credneb » 2015-03-30 08:42:56

[quote]he new beta should also fix the problems you had with the Save command not fully clearing the document's edited state.

[/quote]

Alas, it does not. the behavior remains the same.

Downloaded and unzipped the beta. Installed by simply dragging it to the applications folder. Any other installation steps required?

Cliff

Post Reply