summaryrefslogtreecommitdiff
path: root/helm-command.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2016-06-22 17:40:25 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2016-06-22 17:40:25 +0200
commit4f565a6bd9a48df658e19213c63f1011152bf319 (patch)
tree04ea9ce1986291e6a2fa6e1cec0ad880bc52afef /helm-command.el
parent13a0f17b25155d738053f14e15949226e9713caf (diff)
Change the behavior of xuchunyang patch.
1) Start with M-x doesn't change previous behavior. 2) Start with C-u M-x => navigate (or not) RET execute command with prefix-arg. 3) Start with C-u M-x and then hit C-u disable initial prefix arg, second and next C-u set prefix-arg to new value. * helm-command.el (helm-M-x-allow-prefix-argument): (helm-M-x-map): (helm-M-x-universal-argument): (helm-M-x-read-extended-command): Enable the keymap, remove resetting of helm-M-x-prefix-argument which defeat its purpose. (helm-M-x): Reset initial pref arg.
Diffstat (limited to 'helm-command.el')
-rw-r--r--helm-command.el23
1 files changed, 18 insertions, 5 deletions
diff --git a/helm-command.el b/helm-command.el
index 852966c5..8d79248b 100644
--- a/helm-command.el
+++ b/helm-command.el
@@ -49,7 +49,7 @@ Show all candidates on startup when 0 (default)."
:group 'helm-command
:type 'boolean)
-(defcustom helm-M-x-allow-prefix-argument nil
+(defcustom helm-M-x-allow-prefix-argument t
"Allow specifying prefix argument before `helm-M-x' when non--nil.
Note if you set it to non--nil and specify a prefix argument
before `helm-M-x', then you will NOT be able to cancel it though
@@ -168,6 +168,20 @@ fuzzy matching is running its own sort function with a different algorithm."
(push (substring (helm-cmd--get-current-function-name) 1) results))))
results))
+(defvar helm-M-x-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map helm-comp-read-map)
+ (define-key map (kbd "C-u") 'nil)
+ (define-key map (kbd "C-u") 'helm-M-x-universal-argument)
+ map))
+
+(defun helm-M-x-universal-argument ()
+ (interactive)
+ (if helm-M-x-prefix-argument
+ (setq helm-M-x-prefix-argument nil)
+ (setq prefix-arg (list 4))
+ (universal-argument--mode)))
+
(defun helm-M-x-read-extended-command (&optional collection history)
"Read command name to invoke in `helm-M-x'.
Helm completion is not provided when executing or defining
@@ -234,6 +248,7 @@ than the default which is OBARRAY."
:input-history 'helm-M-x-input-history
:del-input nil
:help-message 'helm-M-x-help-message
+ :keymap helm-M-x-map
:must-match t
:fuzzy helm-M-x-fuzzy-match
:nomark t
@@ -241,9 +256,7 @@ than the default which is OBARRAY."
:fc-transformer 'helm-M-x-transformer
:hist-fc-transformer 'helm-M-x-transformer-hist))
(cancel-timer tm)
- (setq helm--mode-line-display-prefarg nil)
- (when helm-M-x-allow-prefix-argument
- (setq helm-M-x-prefix-argument nil))))))
+ (setq helm--mode-line-display-prefarg nil)))))
;;;###autoload
(defun helm-M-x (arg &optional command-name)
@@ -267,7 +280,7 @@ You can get help on each command by persistent action."
(or helm-current-prefix-arg
(when helm-M-x-allow-prefix-argument
(prog1 helm-M-x-prefix-argument
- (setq helm-M-x-prefix-argument nil)))
+ (setq helm-M-x-prefix-argument nil arg nil)))
arg)))
;; This ugly construct is to save history even on error.
(unless helm-M-x-always-save-history