Function: kbd-key:normalize
kbd-key:normalize is an interactive and byte-compiled function defined
in hib-kbd.el.
Signature
(kbd-key:normalize KEY-SERIES)
Documentation
Normalize a human-readable string of keyboard keys, KEY-SERIES.
The KEY-SERIES is without any surrounding {}. Return the normalized but still human-readable format. Use kbd-key:key-series-to-events to add the key series to Emacs' keyboad input queue, as if they had been typed by the user.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hib-kbd.el
(defun kbd-key:normalize (key-series)
"Normalize a human-readable string of keyboard keys, KEY-SERIES.
The KEY-SERIES is without any surrounding {}. Return the
normalized but still human-readable format. Use
`kbd-key:key-series-to-events' to add the key series to Emacs'
keyboad input queue, as if they had been typed by the user."
(interactive "sKeyboard key sequence to normalize (no {}): ")
;;
;; Hyperbole developers: see `edmacro-parse-keys' in "edmacro.el"
;; for further details on key formats.
;;
(cond ((stringp key-series)
(if (hypb:object-p key-series)
;; Prevent multiple normalizations which can strip desired
;; RET and SPC characters.
key-series
(let ((norm-key-series (copy-sequence key-series))
(case-fold-search nil)
(case-replace t)
;; (substring)
;; (arg)
)
(setq norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series "(" ")")
norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series "\\[" "\\]")
norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series "<" ">")
norm-key-series (kbd-key:mark-spaces-to-keep norm-key-series "\"" "\"")
norm-key-series (replace-regexp-in-string
"<DEL>\\|<DELETE>\\|@key{DEL}\\|\\<DEL\\>" " DEL " norm-key-series nil t)
norm-key-series (replace-regexp-in-string
"<BS>\\|<BACKSPACE>\\|@key{BS}\\|\\<BS\\>" " BS " norm-key-series nil t)
norm-key-series (replace-regexp-in-string
"<RET>\\|<RTN>\\|<RETURN>\\|@key{RET}\\|@key{RTN}\\|\\<RETURN\\>\\|\\<RET\\>\\|\\<RTN\\>"
" RET " norm-key-series nil t)
norm-key-series (replace-regexp-in-string
"<TAB>\\|@key{TAB}\\|\\<TAB\\>" " TAB " norm-key-series nil t)
;; Includes conversion of spaces-to-keep markup to
;; SPC; otherwise, later calls to `kbd' will remove
;; these spaces.
norm-key-series (replace-regexp-in-string
"\\\\ \\|\0\0\0\\|<SPC>\\|@key{SPC}\\|\\<SPC\\>" " SPC " norm-key-series nil t)
norm-key-series (replace-regexp-in-string
"<ESC>\\|<ESCAPE>\\|@key{ESC}\\|\\<ESC\\(APE\\)?\\>" " M-" norm-key-series nil t)
;; ESC ESC
norm-key-series (replace-regexp-in-string
"M-[ \t\n\r\f]*M-" " ESC M-" norm-key-series nil t)
;; Separate with a space any keys with a modifier
norm-key-series (replace-regexp-in-string kbd-key:modified-key-regexp
" \\1\\3 " norm-key-series)
;; Normalize regular whitespace to single spaces
norm-key-series (replace-regexp-in-string "[ \t\n\r\f]+" " " norm-key-series nil t)
;; Unqote special {} chars.
norm-key-series (replace-regexp-in-string "\\\\\\([{}]\\)"
"\\1" norm-key-series)
norm-key-series (hpath:trim norm-key-series))
;; (while (string-match "\\`\\(C-u\\|M-\\)\\(-?[0-9]+\\)" norm-key-series)
;; (setq arg (string-to-number (match-string 2 norm-key-series))
;; norm-key-series (substring norm-key-series (match-end 0))))
(unless (string-empty-p norm-key-series)
(hypb:mark-object norm-key-series))
norm-key-series)))
(t (error "(kbd-key:normalize): requires a string argument, not `%s'" key-series))))