diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-10 20:25:09 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-10 20:50:42 +0200 |
| commit | 1d3db5de9b8c247bb06ab532f587213d426bd95d (patch) | |
| tree | 9e9ce8704c4e5b2ee83f38c885fe41748c301ac2 /menuconfig.py | |
| parent | 25d0b72510928acfc8dab2ae41f2f60fbfa0f382 (diff) | |
menuconfig: Add search with multiple search strings
A search like 'host usb' now finds all symbol names that match both
'host' and 'usb' (as regular expressions), including e.g. USB_MTU3_HOST.
This saves typing a bunch of '.*' and makes it easier to find symbols
when you aren't sure what order the components appear in.
Diffstat (limited to 'menuconfig.py')
| -rwxr-xr-x | menuconfig.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/menuconfig.py b/menuconfig.py index 2f4a6e4..bcb426b 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -141,9 +141,10 @@ _INFO_HELP_LINES = """ # Lines of help text shown at the bottom of the search dialog _JUMP_TO_HELP_LINES = """ -Type text to narrow the search. Regular expressions are supported (anything -available in the Python 're' module). Use the up/down cursor keys to step in -the list. [Enter] jumps to the selected symbol. [ESC] aborts the search. +Type text to narrow the search. Regexes are supported (via Python's 're' +module). The up/down cursor keys step in the list. [Enter] jumps to the +selected symbol. [ESC] aborts the search. Type multiple space-separated +strings/regexes to find entries that match all of them. """[1:-1].split("\n") def _init_styles(): @@ -1363,9 +1364,10 @@ def _jump_to_dialog(): prev_s = s try: - re_search = re.compile(s, re.IGNORECASE).search + regex_searches = [re.compile(regex, re.IGNORECASE).search + for regex in s.split()] - # No exception thrown, so the regex is okay + # No exception thrown, so the regexes are okay bad_re = None # 'matches' holds a list of matching menu nodes. @@ -1373,10 +1375,12 @@ def _jump_to_dialog(): # This is a bit faster than the loop equivalent. At a high # level, the syntax of list comprehensions is # [<item> <loop template>]. - matches = [node - for sym in sorted_syms - if re_search(sym.name) - for node in sym.nodes] + matches = [ + node + for sym in sorted_syms + if all(search(sym.name) for search in regex_searches) + for node in sym.nodes + ] except re.error as e: # Bad regex. Remember the error message so we can show it. |
