From 9237a00f2ac98a401245aa3fd9a0cdcb6ef5ea79 Mon Sep 17 00:00:00 2001 From: Philip K Date: Fri, 29 May 2020 09:35:23 +0200 Subject: [PATCH] Add case-insenstive option to read-multiple-choice --- lisp/emacs-lisp/rmc.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el index 9b253b8857..9a26d94e9b 100644 --- a/lisp/emacs-lisp/rmc.el +++ b/lisp/emacs-lisp/rmc.el @@ -26,7 +26,7 @@ (require 'seq) ;;;###autoload -(defun read-multiple-choice (prompt choices) +(defun read-multiple-choice (prompt choices &optional case-insenstive) "Ask user a multiple choice question. PROMPT should be a string that will be displayed as the prompt. @@ -37,6 +37,9 @@ read-multiple-choice will be displayed in a help buffer if the user requests more help. +If CASE-INSENSTIVE is non-nil, KEY will highlight the first +instance of that letter in NAME, regardless of case. + This function translates user input into responses by consulting the bindings in `query-replace-map'; see the documentation of that variable for more information. In this case, the useful @@ -59,6 +62,7 @@ read-multiple-choice (?s \"session only\") (?n \"no\")))" (let* ((altered-names nil) + (case-fold-search case-insenstive) (full-prompt (format "%s (%s): " @@ -66,7 +70,7 @@ read-multiple-choice (mapconcat (lambda (elem) (let* ((name (cadr elem)) - (pos (seq-position name (car elem))) + (pos (seq-position name (car elem) #'char-equal)) (altered-name (cond ;; Not in the name string. -- 2.20.1