]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (counsel-M-x): Show current-prefix-arg in the prompt
authorOleh Krehel <ohwoeowho@gmail.com>
Fri, 6 Nov 2015 19:35:49 +0000 (20:35 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Fri, 6 Nov 2015 19:36:19 +0000 (20:36 +0100)
* counsel.el (counsel--M-x-prompt): New defun.
(counsel-M-x): Update.

Fixes #287

counsel.el

index dee0e5993ab8496e80a541d61fff20c33ba194ba..9ed334ae5a8c4850b3b288f032f6083409df5c29 100644 (file)
@@ -830,6 +830,20 @@ CMD is a command name."
 (declare-function smex-update "ext:smex")
 (declare-function smex-rank "ext:smex")
 
+(defun counsel--M-x-prompt ()
+  "M-x plus the string representation of `current-prefix-arg'."
+  (if (not current-prefix-arg)
+      "M-x "
+    (concat
+     (if (eq current-prefix-arg '-)
+         "- "
+       (if (integerp current-prefix-arg)
+           (format "%d " current-prefix-arg)
+         (if (= (car current-prefix-arg) 4)
+             "C-u "
+           (format "%d " (car current-prefix-arg)))))
+     "M-x ")))
+
 ;;;###autoload
 (defun counsel-M-x (&optional initial-input)
   "Ivy version of `execute-extended-command'.
@@ -856,7 +870,7 @@ Optional INITIAL-INPUT is the initial input in the minibuffer."
       (setq cands smex-ido-cache)
       (setq pred nil)
       (setq sort nil))
-    (ivy-read "M-x " cands
+    (ivy-read (counsel--M-x-prompt) cands
               :predicate pred
               :require-match t
               :history 'extended-command-history