bondfan wrote: ↑Mon Oct 24, 2022 2:48 am
If you feel like adding some additional functionality, my request would be some saved queries that I can append, for example
query text contains foo and query savedQuery1
with savedQuery1 as
(not titles matches "abcd" and not authorId is 1234)
The reason is that my searches very often return the same few teases + almost all teases of a certain author (mainly shattered :D)
That's a very interesting idea, and certainly something that could be done (although I probably won't have time to get it into the October 31st release, but maybe the next one).
Maybe it could be completely generic rather than being specific to the query command.
Proposal for Variables
Set the variable 'myFavouriteQuery' and persist it:
Code: Select all
> var set myFavouriteQuery '(not title matches "abcd" and not authorId is 1234)'
Use the variable in query commands (or
any command):
Code: Select all
> query $myFavouriteQuery
> query $myFavouriteQuery and title contains banana
> query title contains banana and $myFavouriteQuery and rating >= 3
Because the variables effectively expand in-place, they don't have to be complete standalone expressions:
Code: Select all
> var set tc "title contains"
> query $tc apple
Variables could theorectically form any part of the command input, including the command name:
Code: Select all
> var set qtc "query title contains"
> $qtc apple
> var set someList "list @29180"
> $someList
Get the variable 'myFavouriteQuery':
Code: Select all
> var get myFavouriteQuery
myFavouriteQuery = (not title matches "abcd" and not authorId is 1234)
List all of the variables:
Code: Select all
> var
myFavouriteQuery = (not title matches "abcd" and not authorId is 1234)
tc = title contains
qtc = query title contains
someList = list @17404
Delete the variable 'myFavouriteQuery':
I could extend the tab-completion to support the variables too, such that typing:
$myFav<TAB>
would complete to:
$myFavouriteQuery
or preset the list of possibilities if there is more than one variable name that starts with 'myFav'.
Limitations
For now, I don't think I'll support recursive expansion. For example:
Code: Select all
> var set fw "FrozenWolf"
> var set myQuery author is $fw
> query $myQuery
The '
query $myQuery
' would expand to '
query author is $fw
', i.e. it would not expand '
$fw
'
An issue might be the accidental use of '$':
Rather than changing the variable 'fw' to 'bondfan', this would create a new variable 'FrozenWolf' with 'bondfan'.
Final Thoughts
I'll need to do some careful consideration over the tokenisation of the input during '
var set
' and the tokenisation following the expansion. Quotation marks are an indicator to the tokeniser to keep text together, i.e.
"red apple"
is stored as a single token,
red apple
with the quotes discarded but everything in-between preserved, including spaces. Therefore when the variables are listed, it needs to add quotation marks back in where appropriate so that
red apple
could either be shown as
"red apple"
or
'red apple'
or even
red\ apple
, all of which are equivalent. Anyway, that's my problem to worry about!
Do you think that would suit your needs, or have I missed anything, or can you think of a better way of doing it?
Should the variables be saved to 'config,json' or an alternative file since it's not really configuration?