branch: elpa/iwindow commit f5cf9ed7242404b46de9eefc415dcad5b476e3a9 Author: Akib Azmain Turja <a...@disroot.org> Commit: Akib Azmain Turja <a...@disroot.org>
Don't show raw key code on unbound key --- iwindow.el | 163 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 81 insertions(+), 82 deletions(-) diff --git a/iwindow.el b/iwindow.el index d744f3230f..b1a9c2dfae 100644 --- a/iwindow.el +++ b/iwindow.el @@ -122,27 +122,27 @@ form (OPTION...), whose length of no more than the length of (windows nil) (decorators nil)) (cl-labels ((walk - (tree keys) - (if (windowp tree) - (push (cons tree (reverse keys)) - windows) - (seq-map-indexed - (lambda (node index) - (walk node - (cons (nth index iwindow-selection-keys) - keys))) - tree)))) + (tree keys) + (if (windowp tree) + (push (cons tree (reverse keys)) + windows) + (seq-map-indexed + (lambda (node index) + (walk node + (cons (nth index iwindow-selection-keys) + keys))) + tree)))) (walk tree nil)) (run-hook-wrapped 'iwindow-decoration-functions (lambda (fn) (ignore (push fn decorators)))) (cl-labels ((call-decorators - (fns) - (with-selected-window current-window - (if fns - (funcall (car fns) windows - (lambda () - (call-decorators (cdr fns)))) - (funcall payload))))) + (fns) + (with-selected-window current-window + (if fns + (funcall (car fns) windows + (lambda () + (call-decorators (cdr fns)))) + (funcall payload))))) (call-decorators (nreverse decorators))))) (defun iwindow--ask (tree) @@ -155,7 +155,7 @@ Return the window chosen." (redraw-display)) (let ((option nil) (choices (cl-mapcar #'cons iwindow-selection-keys - tree))) + tree))) (iwindow--decorate-windows tree (lambda () @@ -166,7 +166,8 @@ Return the window chosen." (keyboard-quit) (if-let ((choice (alist-get key choices))) (setq option choice) - (message "Unbound key: %c (press C-g to quit)" key) + (message "Unbound key: %s (press C-g to quit)" + (key-description (list key))) (ding))))))) (iwindow--ask option)))) @@ -196,25 +197,24 @@ WINDOW and ignore WINDOW when PREDICATE returns nil." WINDOWS and CALLBACK is described in the docstring of `iwindow-decoration-functions', which see." (let ((original-mode-lines nil)) - (cl-labels ((setup-windows - (window-list) - (with-selected-window (caar window-list) - (unless (assq (current-buffer) original-mode-lines) - (push (cons (current-buffer) mode-line-format) - original-mode-lines)) - (let ((mode-line-format - `(:eval - (if-let ((keys - (alist-get (selected-window) - ',windows))) - (mapconcat - (apply-partially #'string ? ) - keys "") - ',(alist-get (current-buffer) - original-mode-lines))))) - (if (cdr window-list) - (setup-windows (cdr window-list)) - (funcall callback)))))) + (cl-labels ((setup-windows (window-list) + (with-selected-window (caar window-list) + (unless (assq (current-buffer) original-mode-lines) + (push (cons (current-buffer) mode-line-format) + original-mode-lines)) + (let ((mode-line-format + `(:eval + (if-let ((keys + (alist-get (selected-window) + ',windows))) + (mapconcat + (apply-partially #'string ? ) + keys "") + ',(alist-get (current-buffer) + original-mode-lines))))) + (if (cdr window-list) + (setup-windows (cdr window-list)) + (funcall callback)))))) (setup-windows windows)))) (defun iwindow-highlight-window (windows callback) @@ -225,28 +225,28 @@ WINDOWS and CALLBACK is described in the docstring of (let ((buffers nil) (sym (make-symbol "iwindow-parameter"))) (cl-labels ((setup-windows - (window-list) - (with-selected-window (caar window-list) - (cl-letf* (((window-parameter nil sym) sym) - (payload - (lambda () - (if (cdr window-list) - (setup-windows (cdr window-list)) - (funcall callback))))) - (if (memq (current-buffer) buffers) - (funcall payload) - (let ((face-remapping-alist - face-remapping-alist)) - (cl-letf (((symbol-function - 'make-local-variable) - #'ignore)) - (dolist (pair iwindow-highlight-faces) - (face-remap-add-relative - (car pair) - `(:filtered (:window ,sym ,sym) - ,(cdr pair))))) - (push (current-buffer) buffers) - (funcall payload))))))) + (window-list) + (with-selected-window (caar window-list) + (cl-letf* (((window-parameter nil sym) sym) + (payload + (lambda () + (if (cdr window-list) + (setup-windows (cdr window-list)) + (funcall callback))))) + (if (memq (current-buffer) buffers) + (funcall payload) + (let ((face-remapping-alist + face-remapping-alist)) + (cl-letf (((symbol-function + 'make-local-variable) + #'ignore)) + (dolist (pair iwindow-highlight-faces) + (face-remap-add-relative + (car pair) + `(:filtered (:window ,sym ,sym) + ,(cdr pair))))) + (push (current-buffer) buffers) + (funcall payload))))))) (setup-windows windows)))) (defun iwindow-show-keys-for-minibuffer (windows callback) @@ -254,28 +254,27 @@ WINDOWS and CALLBACK is described in the docstring of WINDOWS and CALLBACK is described in the docstring of `iwindow-decoration-functions', which see." - (cl-labels ((setup-windows - (window-list) - (with-selected-window (caar window-list) - (let ((ov nil)) - (when (minibufferp) - (setq ov (make-overlay (point-min) - (point-min))) - (overlay-put - ov 'before-string - (concat (propertize - (mapconcat #'string (cdar window-list) - " ") - 'face '(iwindow-minibuffer-keys-face - default)) - " ")) - (overlay-put ov 'window (selected-window))) - (unwind-protect - (if (cdr window-list) - (setup-windows (cdr window-list)) - (funcall callback)) - (when ov - (delete-overlay ov))))))) + (cl-labels ((setup-windows (window-list) + (with-selected-window (caar window-list) + (let ((ov nil)) + (when (minibufferp) + (setq ov (make-overlay (point-min) + (point-min))) + (overlay-put + ov 'before-string + (concat (propertize + (mapconcat #'string (cdar window-list) + " ") + 'face '(iwindow-minibuffer-keys-face + default)) + " ")) + (overlay-put ov 'window (selected-window))) + (unwind-protect + (if (cdr window-list) + (setup-windows (cdr window-list)) + (funcall callback)) + (when ov + (delete-overlay ov))))))) (setup-windows windows))) ;;;###autoload