diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2018-06-25 16:17:35 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-07-24 22:05:57 +0100 |
commit | 65dad4acfdc45abfc03b56b9a1860c53a0e85912 (patch) | |
tree | 5b8a36cb81282b72a4b51349031518169fc31610 /alot/commands/search.py | |
parent | 297121e1d6c56424612faa510216b90b1827fad5 (diff) |
new command "savequery"
...that stores a query string as named search.
in Search buffers, this will fall back on the current search string
unless a full query string is provided as (second) argument.
Diffstat (limited to 'alot/commands/search.py')
-rw-r--r-- | alot/commands/search.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/alot/commands/search.py b/alot/commands/search.py index 3e172dd5..d1dccd71 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -7,6 +7,7 @@ import logging from . import Command, registerCommand from .globals import PromptCommand from .globals import MoveCommand +from .globals import SaveQueryCommand as GlobalSaveQueryCommand from .common import RetagPromptCommand from .. import commands @@ -241,3 +242,24 @@ class MoveFocusCommand(MoveCommand): ui.update() else: MoveCommand.apply(self, ui) + + +@registerCommand( + MODE, 'savequery', + arguments=[ + (['--no-flush'], {'action': 'store_false', 'dest': 'flush', + 'default': 'True', + 'help': 'postpone a writeout to the index'}), + (['alias'], {'help': 'alias to use for query string'}), + (['query'], {'help': 'query string to store', + 'nargs': argparse.REMAINDER, + }), + ], + help='store query string as a "named query" in the database. ' + 'This falls back to the current search query in search buffers.') +class SaveQueryCommand(GlobalSaveQueryCommand): + def apply(self, ui): + searchbuffer = ui.current_buffer + if not self.query: + self.query = searchbuffer.querystring + GlobalSaveQueryCommand.apply(self, ui) |