Allow lower-case keys to match upper-case choice options

3 views
Skip to first unread message

Joost Kremers

unread,
Feb 17, 2016, 4:50:15 AM2/17/16
to mu-di...@googlegroups.com
Hi,

I'd like to suggest a small patch to `mu4e~read-char-choice' that will
allow mu4e to accept lower-case characters to match upper-case choice
options if there is no relevant lower-case option.

Some background: I have three contexts corresponding to my mail
accounts, which are called "Fastmail", "Work" and "Gmail". In situations
where mu4e asks me to select a context, I'm presented with a prompt
"[F]astmail, [W]ork, [G]mail", and I have to type `<shift>-f',
`<shift>-w' or `<shift>-g' to select one. Instead, I'd like to be able
to just type `f', `w' or `g'.

The attached patch makes this possible, while still keeping the ability
to have e.g., `f' and `F' stand for different options. Basically, if you
type a lower-case letter, `mu4e~read-char-choice' checks if it occurs as
an option. If not, it converts the choice to upper-case and checks if
that exists. So for example the call:

(mu4e~read-char-choice "Choose: " '(?A ?a ?B ?c))

has the following results:

Press `a' ==> 97 (#o141, #x61, ?a)

Press `A' ==> 65 (#o101, #x41, ?A)

Press `b' ==> 66 (#o102, #x42, ?B)

Press `B' ==> 66 (#o102, #x42, ?B)

Press `c' ==> 99 (#o143, #x63, ?c)

Press `C' ==> (continue waiting for input)

TIA

--
Joost Kremers
Life has its moments

0001-Allow-lower-case-to-match-upper-case-in-a-choice-pro.patch

Dirk-Jan C. Binnema

unread,
Feb 17, 2016, 1:09:04 PM2/17/16
to mu-di...@googlegroups.com
Hi Joost,

On Wednesday Feb 17 2016, Joost Kremers wrote:

> I'd like to suggest a small patch to `mu4e~read-char-choice' that will
> allow mu4e to accept lower-case characters to match upper-case choice
> options if there is no relevant lower-case option.
>
> Some background: I have three contexts corresponding to my mail
> accounts, which are called "Fastmail", "Work" and "Gmail". In situations
> where mu4e asks me to select a context, I'm presented with a prompt
> "[F]astmail, [W]ork, [G]mail", and I have to type `<shift>-f',
> `<shift>-w' or `<shift>-g' to select one. Instead, I'd like to be able
> to just type `f', `w' or `g'.

Think of all the key presses saved! :-)

> The attached patch makes this possible, while still keeping the ability
> to have e.g., `f' and `F' stand for different options. Basically, if you
> type a lower-case letter, `mu4e~read-char-choice' checks if it occurs as
> an option. If not, it converts the choice to upper-case and checks if
> that exists. So for example the call:

I've generalized the idea a bit -- if there's no exact match, we try to
match case-insensitively. It's in git - sorry, it's not your patch, but
in spirit it's there.

Kind regards,
Dirk.


--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Joost Kremers

unread,
Feb 17, 2016, 2:55:05 PM2/17/16
to mu-di...@googlegroups.com
Hi Dirk,

On Wed, Feb 17 2016, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:
>> Some background: I have three contexts corresponding to my mail
>> accounts, which are called "Fastmail", "Work" and "Gmail". In situations
>> where mu4e asks me to select a context, I'm presented with a prompt
>> "[F]astmail, [W]ork, [G]mail", and I have to type `<shift>-f',
>> `<shift>-w' or `<shift>-g' to select one. Instead, I'd like to be able
>> to just type `f', `w' or `g'.
>
> Think of all the key presses saved! :-)

Exactly. ;-)

>> The attached patch makes this possible, while still keeping the ability
>> to have e.g., `f' and `F' stand for different options. Basically, if you
>> type a lower-case letter, `mu4e~read-char-choice' checks if it occurs as
>> an option. If not, it converts the choice to upper-case and checks if
>> that exists. So for example the call:
>
> I've generalized the idea a bit -- if there's no exact match, we try to
> match case-insensitively. It's in git - sorry, it's not your patch, but
> in spirit it's there.

Thanks! And no need to apologize. ;-)
Reply all
Reply to author
Forward
0 new messages