Search and replace in the source tree?

Suppose I want to change the width of all my figures from 0.5par to 0.3par. Searching in the document can’t find those keywords. So I switch to the source tree view, but searching in the source does not work at all. Of course, it’s better if the search and replace can be done directly in the document.

A related feature could be searching and replacing labels and references. This is very useful for finding where an equation is referred or replacing a label name.

I think what you want can be realized with the tree-searching Scheme functions. I took a look at the manuals and at code that @jeroen and I wrote some time ago and I have to spend a bit of time with it before I understand it again. Perhaps you find it helpful: How can I see list of labels?

The tree-searching function you want is tree-search; see message How can I see list of labels? and following ones. Please let me know if it is a start.

Also have a look at using wildcards in the search and replace tool.

I thought it could not work because I cannot find <tuple|geometry|_wildcard_|_wildcard_> (for a drawing), then I have been able to find the images with 360pt width using

<inactive|<image|<tuple|<wildcard|x>|<wildcard|y>>|360pt|<wildcard|z>|<wildcard|w>|<wildcard|t>>>

that I obtained by inserting the tag image in the search and replace tool, and then correcting by hand the wildcards that I could not put in with a shortcut. Perhaps the tool can search only starting from the “outermost” tags?
I also found the same images activating the above construct.

On the other hand I have not been able to replace the images with the same ones with 240pt width, with either the inactive or the activated tag. Perhaps I do not understand how to use wildcards.

@Jade: instructions on how to use the search and replace tool are in the “Search and replace” section of the manual (8.2 in the current edition).

Searching can be done with the following.


For replacing, I have to put a wildcard as the first argument in order to find anything.

However, the replaced result is incorrect, it replaces the url of the image by the wildcard!
image

Maybe I am using the wildcard in a wrong way?

No problem for searching and replacing references this way (haven’t tested wildcards). Labels can also be searched. But it finds one type a time. For example, to find labels for equations, the cursor must be in an equation to start with, which is a good thing in some sense.

I get the same and I do not know how to get the “correct result”. Perhaps it is a bug: it works if for example you want to change the caption of a big-figure.

Yes, it seems to be broken. I get similar outcomes with equation*, while eqnarray* does work.

Today, when I was preparing the bug report, activating the image tag within the search tool made the replacement of the width with a different width work. Yesterday I think it had not worked either way, with either the activated or inactivated tag, but I had tried just a little with the activated tag and I may have missed something.
@Jade might want to try.
I am also going to see whether I can do the replacement with Scheme, but if the tool works, it is better.

In addition to that I was not able to reproduce the malfunctioning with equation*.

A smaller bug seems that the search works only just after one inserts the search term in the window; after “something happens” (I do not know what “something” is) the search does not work anymore, and one has to delete everything in the window and start the insertion from the beginning.

Yes, activating the tag works, even though it shows error in the activated tag.

1 Like