From ba1d2321e87dff688eca44f22c3ee07f3c4efbba Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 7 Dec 2014 20:29:04 -0500 Subject: Update commander for upstream changes See Projectile commit 2fd7ec96465aea135ff9017ce7f2001f870f7765. --- bog.el | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'bog.el') diff --git a/bog.el b/bog.el index 130a1c1..d0d3b51 100644 --- a/bog.el +++ b/bog.el @@ -835,20 +835,11 @@ to invoke. Press \"?\" to describe available actions. See `def-bog-commander-method' for defining new methods." (interactive) - (message "Commander [%s]: " - (apply #'string (mapcar #'car bog-commander-methods))) - (let* ((ch (save-window-excursion - (select-window (minibuffer-window)) - (read-char))) - (method (cl-find ch bog-commander-methods :key #'car))) - (cond (method - (funcall (cl-caddr method))) - (t - (message "No method for character: ?\\%c" ch) - (ding) - (sleep-for 1) - (discard-input) - (bog-commander))))) + (-let* ((choices (-map #'car bog-commander-methods)) + (prompt (concat "Commander [" choices "]: ")) + (ch (read-char-choice prompt choices)) + ((_ _ fn) (assq ch bog-commander-methods))) + (funcall fn)) ) (defmacro def-bog-commander-method (key description &rest body) "Define a new `bog-commander' method. @@ -862,9 +853,9 @@ chosen." (let ((method `(lambda () ,@body))) `(setq bog-commander-methods - (cl-sort (cons (list ,key ,description ,method) - (cl-remove ,key bog-commander-methods :key #'car)) - #'< :key #'car)))) + (--sort (< (car it) (car other)) + (cons (list ,key ,description ,method) + (assq-delete-all ,key bog-commander-methods)))))) (def-bog-commander-method ?? "Commander help buffer." (ignore-errors (kill-buffer bog-commander-help-buffer)) -- cgit v1.2.3