Reply to topic  [ 7 posts ] 
find and replace by attribute 
Author Message

Joined: 2009-01-05 04:12:43
Posts: 4
I'm afraid I'm new to all this, so bear with me please...

I have a document to which I have applied strikethroughs to indicate sections that have been superceded. I want to select and delete these sections to produce 'clean' text for the next version of the document.

I bought 'pro' as it allows searching with attributes - but it can't seem to search for >any text with a given attribute< - in any case, there seems no way within the 'find' system to describe the attribute I want.

So I think that a macro may do it, but again, I can't find any way to refer to the strikethrough attribute.

Can anyone help?

Thanks!


2009-01-05 09:31:30
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
You don't need a macro for this. Here's what to do:

1. Open the Find & Replace window.
2. Use the "gear" button under "find what" to insert the PowerFind bubble Wild Card > Any Text.
3. Select the bubble in the "find what" field.
4. Make sure the menu Format > Any Attributes is checked. This is to ensure you don't have any unwanted stray attributes present.
5. With the PowerFind bubble still selected, use the menu Format > Strikethrough > Single.

That last step should automatically turn on the "attribute sensitive" option underneath the find field. Now just press the "Next" or "Find All" button.


2009-01-05 13:35:09
Profile WWW

Joined: 2009-01-05 04:12:43
Posts: 4
Thanks, Martin - a door has been unlocked to me!


2009-01-06 03:00:30
Profile

Joined: 2008-05-27 08:39:25
Posts: 8
Dear all,

I've got a follow-up question. A macro would save a lot of time in the long run since it's several steps, in my case the transformation of certain abbreviations from small caps to CAPS.
(for me, it's a follow-up to my "CAPS to small caps" thread below, to have simple commands for both directions)

What I'd like to have is a macro that finds all text displayed as small caps and transforms it to CAPS.
The search in first line is for a specific kind of abbreviations (grammatical glosses).
The last four lines should work for the transformation.
But how do I find the small caps in the first place?

I can't figure out how to add the 'display as …'.

XXX $numFound = Find All '[a-z]{2,}|[mfn](?=[-:.) /=])', 'E-is'
if $numFound > 0 # Just 'if $numFound' will do the same
Menu "Display as lowercase"
Menu "To UPPERCASE"
end


Btw, I use 'display as small caps' because there was some issue with 'convert to caps' and some fonts.

Thanks for any help and sorry if I've missed an obvious explanation.

thyx

_________________
Thomas Hanke


2009-02-03 10:20:19
Profile

Joined: 2008-05-27 08:39:25
Posts: 8
I guess, what I need is in line with Kino's explanation over there:
viewtopic.php?f=17&t=3089

But I'm sorry that I can't grasp how there to here, i.e. 'display as …'.

thyx

_________________
Thomas Hanke


2009-02-03 10:32:45
Profile

Joined: 2008-05-27 08:39:25
Posts: 8
Heureka… I guess I found the solution.

I've read some more and found among others Kino's mentioning of "Set Find Shown":
viewtopic.php?f=17&t=3185

Then it took me some time to realize how useful "Set Find Shown true" is.
Anyway, after some more experimenting I came up with the following.
I’m glad for any comments.

Code:
Find and Replace '[a-z]+', '\0', 'EiuUas'
Set Find Shown true
Menu "remove attributes and styles"
Menu "Format:Character Case:Display as Small Caps"
Menu ":Edit:Find:Find All"
Set Find Shown false
Menu "remove attributes except styles"
Menu "To uppercase"


I think I finally got the 'Find and Replace' options all right. That works for all occurrences of one or more letter in the present selection.

I didn't get that far without the "Set Find Shown true/false" part.
Is it just me or is that part of Nisus not (yet) described systematically?
Google has just three hits, all from Kino:
http://www.google.com/search?client=saf ... 8&oe=UTF-8

Thanks, once again, to Kino!

Sorry if this is obvious for anyone, but I haven't found any documentation.
Mmh, that access to the find format could be useful for a lot of things…

thyx

_________________
Thomas Hanke


2009-02-03 12:49:08
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Glad you made it- always satisfying to get something working! I have a couple of comments/tips that may be helpful.
thyx wrote:
Code:
Find and Replace '[a-z]+', '\0', 'EiuUas'

The options you give to the command aren't exactly what you want.

First, you are missing the "!" option, which sets the Find & Replace window to use the options/patterns you've specified in the macro command instead of actually running a find/replace operation. If you do not include it, the "Find All" command you issue later will just find whatever happened to be in the find window previously.

Also, the "U" option, to do attribute sensitive replacement, is superfluous because you don't actually need to do any replacing. Instead you're simply modifying the attributes of the found text via the menus.

So, the modified macro becomes:
Code:
Find All '[a-z]+', 'Eiuas!'
Set Find Shown true
Menu "remove attributes and styles"
Menu "Format:Character Case:Display as Small Caps"
Menu ":Edit:Find:Find All"
Set Find Shown false
Menu "remove attributes except styles"
Menu "To uppercase"


I would also offer up the following alternative macro, which is slightly more efficient and leaves the Find & Replace window unchanged:
Code:
Find All '[a-z]+', 'Eiuas'
Menu "remove attributes except styles"
Menu "To uppercase"

The trick with that macro is you must apply the proper attributes to the find pattern. In your case you want the "Display as Small Caps" attribute present, and no others. To do that select the entire first line of the macro (eg: the entire Find All command), then apply the following menus:

1. Format > Remove Attributes and Styles (this will apply the Normal paragraph style, if it exists)
2. Format > Paragraph Style > Remove Style
3. Format > Character Case > Display as Small Caps

The first two menus ensure that no attributes are applied to the expression, and the second applies the attribute you want to match.

Quote:
Is it just me or is that part of Nisus not (yet) described systematically?
Google has just three hits, all from Kino

Yes, Kino's examples are a great resource. We do have the Nisus Macro Reference, which is included in the NWP disk image or available for download in the macro repository. It lists all available macro commands, even if it doesn't necessarily explain how they might be useful.


2009-02-03 14:42:03
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 1 guest


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:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software