diff options
author | jao <jao@gnu.org> | 2021-01-22 02:43:35 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2021-01-22 02:43:35 +0000 |
commit | 14ac8cbfa7a6d497f4c0016b7bc4c5ce5185aeba (patch) | |
tree | ea44e298b96bea10c19ffef27c998296abd7d476 | |
parent | cf6007637e972271a0c1d9d9a0744536454a9e75 (diff) | |
download | elibs-14ac8cbfa7a6d497f4c0016b7bc4c5ce5185aeba.tar.gz elibs-14ac8cbfa7a6d497f4c0016b7bc4c5ce5185aeba.tar.bz2 |
which-keyish embark prompter sans 2k loc imported
-rw-r--r-- | eos/jao-embark-prompter.el | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/eos/jao-embark-prompter.el b/eos/jao-embark-prompter.el new file mode 100644 index 0000000..969111e --- /dev/null +++ b/eos/jao-embark-prompter.el @@ -0,0 +1,64 @@ +;;; jao-embark-prompter.el --- a prompter for embark -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 jao + +;; Author: jao <mail@jao.io> +;; Keywords: convenience + +;; This program 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. + +;; This program 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 this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Custom action prompting + +;;; Code: + +(defun jao-embark--show-keymap (keymap) + (with-current-buffer (cvs-get-buffer-create "*Embark Actions*") + (read-only-mode -1) + (setq-local cursor-type nil) + (delete-region (point-min) (point-max)) + (seq-each (lambda (x) + (let ((k (car x)) (c (cdr x))) + (unless (embark--omit-binding-p c) + (let ((desc (if (numberp k) + (single-key-description k) + (key-description k))) + (cmd (symbol-name c))) + (insert (propertize desc 'face 'embark-keybinding) + embark-key-action-separator + (symbol-name c) + "\n"))))) + (cdr (keymap-canonicalize keymap))) + (insert "Action? ") + (read-only-mode 1) + (pop-to-buffer (current-buffer) nil t))) + +(defun jao-embark--prompter (keymap) + (let* ((buf (jao-embark--show-keymap keymap)) + (cmd (embark-keymap-prompter keymap))) + (embark-kill-buffer-and-window buf) + cmd)) + +(advice-add 'embark-completing-read-prompter :override + #'jao-embark--prompter) + +(add-to-list 'display-buffer-alist + '("\\`\\*Embark Actions*\\*" + (display-buffer-at-bottom) + (window-parameters (mode-line-format . none)) + (window-height . fit-window-to-buffer))) + +(provide 'jao-embark-prompter) +;;; jao-embark-prompter.el ends here |