From 81c7786402fabcd2a968481825b053c8ba039c6b Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 17 Feb 2016 20:01:18 +0200 Subject: [PATCH] mu4e: make mu4e~read-char-choice case-insensitive Make mu4e~read-char-choice case insensitive if there is no exact match. Small convenience. --- NEWS.org | 3 +++ mu4e/mu4e-utils.el | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NEWS.org b/NEWS.org index 7b65bac7..90857056 100644 --- a/NEWS.org +++ b/NEWS.org @@ -17,6 +17,9 @@ - Make `shr' the default renderer for rich-text emails - Allow for resending existing messages, possibly editing them. M-x mu4e-compose-resend, or use the menu; no shortcut. + - Let `mu4e~read-char-choice' become case-insensitive if there is + no exact match; small convenience that affects most the + single-char option reading in mu4e. ** 0.9.16 diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index 25105ff6..8948b26b 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -228,14 +228,18 @@ Does a local-exit and does not return. In emacs versions below (user-error "%s" (apply 'mu4e-format frm args))) (defun mu4e~read-char-choice (prompt choices) - "Compatiblity wrapper for `read-char-choice'. -That function is available which emacs-24 only." - (let ((choice) (ok) (inhibit-quit nil)) - (while (not ok) + "Read and return one of CHOICES, prompting for PROMPT. +Any input that is not one of CHOICES is ignored. This mu4e's +version of `read-char-choice', that becomes case-insentive after +trying an exact match." + (let ((choice) (chosen) (inhibit-quit nil)) + (while (not chosen) (message nil);; this seems needed... (setq choice (read-char-exclusive prompt)) - (setq ok (member choice choices))) - choice)) + (setq chosen (or (member choice choices) + (member (downcase choice) choices) + (member (upcase choice) choices)))) + (car chosen))) (defun mu4e-read-option (prompt options) "Ask user for an option from a list on the input area.