Reply to topic  [ 7 posts ] 
macro to delete "tracks" containing certain characters 
Author Message

Joined: 2007-01-17 05:46:17
Posts: 145
Location: Tokyo, Japan
Hello,

I am editing a file containing an enormous number of "track changes -- and I notice that NWP is very weak to deal with this kind of documents. If I open and edit it in MS Word, there are almost no problems, but in NWP, each change takes minutes and each time, the rainbow wheel is turning indefinitly... I really would like to request a better treatment of this kind of documents...

Anyway, this enormous number of "track changes" is the result of several "change all" for formatting. The editor who made these changes made "change all" to change all the spaces after "«" and before "»" into "non-breaking spaces". This is correct in terms of editing process, but leaving all these changes in "track changes" seems to me a rather silly thing...

Anyway, what I would love to have is a macro that would select every instance of "track change" which contains a "non-breaking space". Is such a macro possible?

Thank you very much in advance to whoever would be so kind as to write for me this macro...

Best regards,

Nobumi

_________________
Best regards,

Nobumi Iyanaga
Tokyo,
Japan


2017-07-18 17:47:49
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Hi Nobumi,

Here's a macro that finds text in tracked changes. It will search all tracked deletions and replacements in your document, selecting those whose original (ie: deleted) text matches the search text. You can then either accept or reject them all.

As an aside, are you able to send us your document privately, so I can see the slowdown firsthand? I'd like to see if there's anything we can do to help Nisus Writer behave more smoothly. Thanks!


2017-07-19 17:14:14
Profile WWW

Joined: 2007-01-17 05:46:17
Posts: 145
Location: Tokyo, Japan
Hello Martin,

Thank you for your reply and your excellent macro!

You wrote:
Quote:
Here's a macro that finds text in tracked changes. It will search all tracked deletions and replacements in your document, selecting those whose original (ie: deleted) text matches the search text. You can then either accept or reject them all.


The macro worked very well. I could delete (that is, accept) more than 300 changes. -- But there are much more of the same kind, in which no traces of deleted text seem to be left; there are only the added elements which are indicated in the side bar...

It seems that NWP macro language lacks the "
Code:
.addedTextContent"
property among the TrackedChange Object Properties. But going through the "
Code:
.markedText"
or "
Code:
.markedTextRange
"..., it seems possible to get the values of the added text?? The macro would be much more complicated, but is it possible to write such a macro, please...?

Thank you very much in advance!

You wrote also:
Quote:
As an aside, are you able to send us your document privately, so I can see the slowdown firsthand? I'd like to see if there's anything we can do to help Nisus Writer behave more smoothly. Thanks!


Yes, surely. I will send you the file in a feedback. Thank you in advance for examining it, and see how it would be possible to improve NWP's behavior.

Best regard,

Nobumi Iyanaga

_________________
Best regards,

Nobumi Iyanaga
Tokyo,
Japan


2017-07-20 06:22:12
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
I'm very happy to help!
Nobumi Iyanaga wrote:
The macro worked very well. I could delete (that is, accept) more than 300 changes. -- But there are much more of the same kind, in which no traces of deleted text seem to be left; there are only the added elements which are indicated in the side bar...

Ah yes, I should have anticipated this need. Here's an amended macro that can search tracked deletions and additions.

Quote:
It seems that NWP macro language lacks the "
Code:
.addedTextContent"
property among the TrackedChange Object Properties. But going through the "
Code:
.markedText"
or "
Code:
.markedTextRange
"..., it seems possible to get the values of the added text??

Yes, the trick is to set the selection to the marked text/range and then search only within the selection. You can see how it works in the updated macro.

Quote:
Yes, surely. I will send you the file in a feedback.

Great, I'll be on the lookout for it, thank you!


2017-07-20 07:05:52
Profile WWW
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Nobumi Iyanaga wrote:
It seems that NWP macro language lacks the "
Code:
.addedTextContent"
property among the TrackedChange Object Properties. But going through the "
Code:
.markedText"
or "
Code:
.markedTextRange
"..., it seems possible to get the values of the added text?? The macro would be much more complicated, but is it possible to write such a macro, please...?

You should be able to use
Code:
$addedText = $change.markedText.subtextInRange($change.markedTextRange)


But of course if you do a find on this subtext (or substring) the returned range values will not be applicable to the main text. That is why Martin does the find via the GUI.
The range value for the main text would have to be calculated with something like this:

Code:
$isMatch = $addedText.find($findText, $findOps)
if $isMatch
    $findRange = Range.new $change.markedTextRange.location + $isMatch.location, $isMatch.length
end


NB: I have not tested any of this.

_________________
philip


2017-07-20 22:57:39
Profile

Joined: 2007-01-17 05:46:17
Posts: 145
Location: Tokyo, Japan
Hello Martin,
Hello Philip,

Thank you for your new macro, Martin. I downloaded it and used it. It works perfectly, as I have expected. This helped much, and now, with much less "track changes", I can edit my document without difficulties. Thank you very much again!

As Philip points out, you use "GUI Find" to test if a track changed text contains an added item that matches those items to be found -- and this seems to slow down the macro...? But this is not a major problem; anyway, with your macro, I could make the file "workable".

Philip's codes seem very interesting, but I don't understand how they should be inserted in Martin's macro.

Anyway, I find that it is rather not very intelligent to record these kinds of "Replace All" in track changes (for example Replace All every space with a non-breaking-space for cases like "« " or " »", etc.); but there are certainly people who do that. NWP should be able to deal with this kind of files too...

Best regard,

Nobumi Iyanaga

_________________
Best regards,

Nobumi Iyanaga
Tokyo,
Japan


2017-07-23 06:21:12
Profile WWW
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Hello Nobumi,
Nobumi Iyanaga wrote:
Philip's codes seem very interesting, but I don't understand how they should be inserted in Martin's macro.

I had a more careful look at Martin's code, and I see that he doesn't make use of the find on the added text after all. He really just checks for presence of the find text. So the change to the macro is really simple:

Martin's code:
Code:
   If $isSearchAdditions
      $markedText = $change.markedText
      If $markedText
         $markedRange = $change.markedTextRange
         If $markedRange
            $select = TextSelection.new($markedText, $markedRange)
            $doc.setSelection($select)
            If Find $findText, "s$findOps"
               $isMatch = @TRUE
            End
         End
      End
   End


Changed code:
Code:
   If $isSearchAdditions
      $markedText = $change.markedText
      If $markedText
         $markedRange = $change.markedTextRange
         If $markedRange
            $addedText = $markedText.subtextInRange($markedRange)
            $isMatch = $addedText.find($findText, $findOps)
         End
      End
   End


Here is a copy of the macro with the change included.
Attachment:
Find in Tracked Changes.nwm [5.55 KiB]
Downloaded 27 times


Nobumi Iyanaga wrote:
Anyway, I find that it is rather not very intelligent to record these kinds of "Replace All" in track changes (for example Replace All every space with a non-breaking-space for cases like "« " or " »", etc.); but there are certainly people who do that. NWP should be able to deal with this kind of files too...

This problem strikes me as the fundamental problem with Tracked Changes and why I never use them in the first place. The machine simply has no way to know the difference between a meaningful change and a cosmetic change. So unless you constantly weed through the changes and accept the cosmetic ones you end up with a document heavy with changes, and you end up with a "needle in the haystack" problem. Managing the changes can be more work than is gained by tracking them.

_________________
philip


2017-07-23 09:01:53
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software