Update: DFHack r3 comes with this plugin built in. There is no need for a separate download
I've been working on a DFHack plugin to add search/filtering functionality to some of the screens with long lists, similar to what exists in the "Move to Depot" and "Manager" screens. This should hopefully make it a bit easier to find specific items in those lists (e.g. the Trade window; to find the items you want to buy).
I've added it to the Stocks, Trading, Unit List, Stockpile, Animals, Military positions assignment, Announcements, Room list, Job list, Burrow assignment, as you can see in the screenshots below. It's fairly simple to use; works the same way as the search option in "Move to Depot" does. You will see the Search option displayed on screen with a hotkey (usually 's'). Pressing it lets you start typing a query and the relevant list will start filtering automatically. Pressing ENTER, ESC or the arrow keys will return you to browsing the now filtered list, which still functions as normal. You can clear the filter by either going back into search mode and backspacing to delete it, or pressing the "shifted" version of the search hotkey while browsing the list (e.g. if the hotkey is 's', then hitting 'shift-s' will clear any filter). Leaving any screen automatically clears the filter.
This is how it looks on the Stocks screen, here filtering the crossbows with "cro". The search option is only enabled when you have "tabbed" to see individual items. The filter will persist as you scroll through categories. Since DFHack knows about item quality and decorations, you can also use the search to filter objects by quality (use '-', '+', '*', '=', '@' to define quality and '<' or '>' to match decorated items).
This is the Trade window. This one has two search options, to filter the merchant's goods and your goods separately. I couldn't use 's' as a hotkey here as it was already in use, so went with 'q' and 'w'. As you can see, when typing in a filter, the active search option is highlighted green.
Note that the Trade Value you see will always be of the active filtered lists. For example, if you search for "cloth b" to find all the cloth bins, mark them all, then do another search for "cages", you'll notice that the "Trade Value" field has gone to zero. That's because the cloth bins are not in this set of search results. However, they are still tracked behind the scenes, so you can mark all the cages you found, then clear the filter and you'll notice the trade value goes up to include the marked cloth bins too... if you scroll through the list you should find everything marked correctly.
If you press 't' to trade with the filter active, instead of doing the trade the filter will be cleared... otherwise the trade itself will not work correctly.
Here's how it looks on the Unit list screen. The search will work on any tab, including the Animals (and filters on animal types too).
Filtering animal types:
Anyway, I hope this is useful for some people. Let me know if you notice any issues.