Function: rmc--add-key-description
rmc--add-key-description is a byte-compiled function defined in
rmc.el.gz.
Signature
(rmc--add-key-description ELEM)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/rmc.el.gz
;;; rmc.el --- read from a multiple choice question -*- lexical-binding: t -*-
;; Copyright (C) 2016-2024 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(defun rmc--add-key-description (elem)
(let* ((char (car elem))
(name (cadr elem))
(pos (seq-position name char))
(desc (key-description (char-to-string char)))
(graphical-terminal
(display-supports-face-attributes-p
'(:underline t) (window-frame)))
(altered-name
(cond
;; Not in the name string, or a special character.
((or (not pos)
(member desc '("ESC" "TAB" "RET" "DEL" "SPC")))
(format "%s %s"
(if graphical-terminal
(propertize desc 'face 'read-multiple-choice-face)
(propertize desc 'face 'help-key-binding))
name))
;; The prompt character is in the name, so highlight
;; it on graphical terminals.
(graphical-terminal
(setq name (copy-sequence name))
(put-text-property pos (1+ pos)
'face 'read-multiple-choice-face
name)
name)
;; And put it in [bracket] on non-graphical terminals.
(t
(concat
(substring name 0 pos)
"["
(upcase (substring name pos (1+ pos)))
"]"
(substring name (1+ pos)))))))
(cons char altered-name)))