wangp / bower

A curses terminal client for the Notmuch email system
Other
119 stars 11 forks source link

Use Alt+Key for fast alias expansion in index view #72

Closed seifferth closed 3 years ago

seifferth commented 3 years ago

Cf. https://github.com/wangp/bower/issues/31. This commit adds Alt+Key keybindings to the index view. Pressing Alt+Key will treat Key as a single letter search alias that is invoked directly without prompting the user to enter more text. This provides a slightly more convenient way to switch between frequent queries.

I also decided to keep aliases out of the search history if invoked via Alt+Key. Having all those implicitly invoked standard searches in the history would have felt a lot like cluttering it unnecessarily.

wangp commented 3 years ago

Interesting idea. I can't really see a problem with it except that we might want to introduce an Alt key binding one day (probably unlikely), which would potentially conflict with someone's configuration. Well, it would be an easy fix for the user.

Another option is simply a two key sequence, e.g. c x could invoke the search ~x.

seifferth commented 3 years ago

Another option is simply a two key sequence, e.g. c x could invoke the search ~x.

True, but then we do already have a three key sequence that does already this: ~<Key><Enter>.

I can't really see a problem with it except that we might want to introduce an Alt key binding one day (probably unlikely)

True again. But as we don't use Alt yet, I figured that this should be fine for now. As you said, we could still reserve some Alt+Key combinations later on. I don't really think that the need would ever arise, though. Even if we reserve Alt for search term expansion, we are still left with way more unused keys than we should ever need. Also note that this only affects the index view, so Alt is still free for use in all the others.

wangp commented 3 years ago

Merged. Let's try it out.

seifferth commented 3 years ago

Tanks for merging. About commit fc8261f1 (Restrict Alt+Key to ASCII letters or digits only). I just checked if German non-ASCII characters work with the previous version, and they do. So I am reasonably sure that curses does handle UTF-8 quite well.

I guess that the ASCII range should be wide enough anyway, but if this uncertainty is the only reason for the restriction, I'd be happy to take care of testing non-ASCII characters occasionally.

wangp commented 3 years ago

You're right. It was only my intention to filter out control characters, Alt+Backspace, Alt+Enter and so on. I've relaxed it to allow any "printable" character as defined by isprint, which is the same test we use for the text entry module so it should be okay.

seifferth commented 3 years ago

It was only my intention to filter out control characters, Alt+Backspace, Alt+Enter and so on.

That sounds reasonable. I hadn't thought of Enter and Backspace, honestly. Thanks for relaxing the rule.