RealRaven2000 / QuickFolders

Thunderbird Add-on: QuickFolders
http://quickfolders.org/
Other
49 stars 9 forks source link

New feature: find related = search filter based on currently selected mail #488

Open RealRaven2000 opened 2 months ago

RealRaven2000 commented 2 months ago

Just leaving this experimental feature here for the moment (it may go into its own Add-on at one stage). I often need to filter the current folder based on the (subject of) the currently selected email. I usually select a portion of the subject line and then paste it into the Thunderbird QuickFilter textbox - if the box is currently hidden I have to hit CTRL+Shift+K first:

image

I use this to list related orders based on a customer's name which shows up in the subject line - usually, in addition to Subject I have filter by Sender and Recipients also enabled but in this example it would not work as it is my own name. I have not enable [Body] as this is faster than searching all body of many emails.

So this is quite a complex set of actions I need to carry out that also involve the mouse, I would like it to be a single click operation, based on a regular expression. In this case a functional regex would be:

"Order: (QUI\d*\-\d*\-\d*) - (.*) -"

, with the group argument being 2 (the second set of parentheses will return the searched result, the customer name. It would be best to add a button to the current folder bar (a.k.a Navigation bar) which is located in center screen to automate this operation. A second click on the same button could somehow clear the search box again (this could be based on the same search term already being displayed). Additional functionality would be to select a predefined set of the 4 filter criteria buttons (sender, recipients, subject, body) for the search and then returning to a default setting when the search is reset to "None".

I think I can use the webextension APIs for the actual filtering, namely mailTabs.setQuickFilter() .

RealRaven2000 commented 2 months ago

Here is the first trial version for the feature:

New interfaces - enable in options (to make this visible a valid QuickFolders Pro license is required)

image

Clicking the configuration wheel to the right opens up the detailed settings:

image

extensions.quickfolders.findRelated.pattern - a regular expression string representing a search pattern that can be used to retrieve a matching string from the currently selected email. FOr example, use "\[.*\]" to capture a word or group of words that are in square brackets

extensions.quickfolders.findRelated.group - number of match group. 0 represents the complete match, higher numbers are for following (search groups). Please reger to regex101.com for detail.

extensions.quickfolders.findRelated.searchSelected - an array of fields that are used to retrieve the search string from the current mail. E.g. ["subject"] to only search the subject line of the currently selecte mail for a match. Once a match is found, it is inserted in the quick filter field of Thunderbird to filter all visible emails. If nothing is found, no filter is set.

extensions.quickfolders.findRelated.searchCriteria - an array of fields that can be matched to generate the matching mail resultset. E.g. use ["subject","author","recipients"] to search subject lines, senders and recipients for the search term.

Example

I want to find related mails by customer, and I know my mails have subject lines of the following format:

Order: QUIxxxx-xxxx-xxxx - customerName - productname

where xxxx is an arbitrary number of digits.

pattern = "Order: (QUI\d-\d-\d) - (.) -" group = 2 searchSelected = ["subject"]

This defines the pattern, note that the second (expression in parentheses) contains the name of the customer (hence group=2). The patter specified that the name will be between "- name -" and has any arbitrary format. It retrieved from the subject (searchSelected) only. Once a result is retrieved the quick filter will be filled with the name and the filter options specified in searchCriteria will be activated, for example ["subject","recipients"] - so any email that is sent to the retrieved name or mentions the name in the subject line.

In future versions we can build a proper interface for settings these parameters, but for now we have something that can already be used to find matching emails in a flexible manner.

QuickFolders-mx-6.6.2pre33.zip


To try the version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

BGMcoder commented 1 month ago

There used to be an addon for Thunderbird long ago called "Pivot". There was a toolbar button. You push it, and it would change the quickfilter to display messages related to the current message. It had teeny buttons for parameters - you could pivot on the subject, authour, keywords, etc. I loved this and got used to it and I've missed it ever since until XUL went out the door. (old addon is attached) qfb_pivot-1.1-tb.zip

RealRaven2000 commented 1 month ago

There used to be an addon for Thunderbird long ago called "Pivot". There was a toolbar button. You push it, and it would change the quickfilter to display messages related to the current message. It had teeny buttons for parameters - you could pivot on the subject, authour, keywords, etc. I loved this and got used to it and I've missed it ever since until XUL went out the door. (old addon is attached) qfb_pivot-1.1-tb.zip

Thanks for sharing - I will have a look when I get time. My current plan is to just the button on the navigation bar and a dropdown list with different patterns that the user can set the filter to. The UI for setting (and maybe testing) these filters will be in a new tab in QuickFolders settings, see the latest version:

image

(the settings don't work yet but they will at least display the controls shown above, of course more well designed)

QuickFolders-mx-6.8pre24.zip


To try the version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)