diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2019-11-13 18:41:46 +0100 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2019-11-13 18:41:46 +0100 |
commit | c22b1a51ed266d4d5bd83bb7129c1f294ab8c0b6 (patch) | |
tree | 415adc8784d1e340a3db5c36e785eca202f808ba /helm-command.el | |
parent | 2c0735c85ca700874a92a2c7a2e828c17a706e54 (diff) |
Make helm-M-x using completion-styles
* helm-lib.el (helm-dynamic-completion): New.
* helm-command.el (helm-M-x-read-extended-command): Use it.
Diffstat (limited to 'helm-command.el')
-rw-r--r-- | helm-command.el | 102 |
1 files changed, 67 insertions, 35 deletions
diff --git a/helm-command.el b/helm-command.el index 54aae483..67db7533 100644 --- a/helm-command.el +++ b/helm-command.el @@ -212,7 +212,24 @@ than the default which is OBARRAY." (tm (run-at-time 1 0.1 'helm-M-x--notify-prefix-arg)) (helm-move-selection-after-hook (cons (lambda () (setq current-prefix-arg nil)) - helm-move-selection-after-hook))) + helm-move-selection-after-hook)) + (sources (and (eq helm-completion-style 'emacs) + `(,(helm-build-sync-source "Emacs Commands" + :candidates (helm-dynamic-completion + (or collection obarray) + #'commandp) + :match-dynamic t + :requires-pattern helm-M-x-requires-pattern + :filtered-candidate-transformer 'helm-M-x-transformer + :persistent-action (lambda (candidate) + (helm-elisp--persistent-help + candidate 'helm-describe-function)) + :persistent-help "Describe this command" + :group 'helm-command + :keymap helm-M-x-map) + ,(helm-build-sync-source "Emacs Commands history" + :candidates (lambda () (or history extended-command-history)) + :filtered-candidate-transformer 'helm-M-x-transformer-hist))))) (setq extended-command-history (cl-loop for c in extended-command-history when (and c (commandp (intern c))) @@ -221,40 +238,55 @@ than the default which is OBARRAY." (unwind-protect (progn (setq current-prefix-arg nil) - (helm-comp-read - (concat (cond - ((eq helm-M-x-prefix-argument '-) "- ") - ((and (consp helm-M-x-prefix-argument) - (eq (car helm-M-x-prefix-argument) 4)) "C-u ") - ((and (consp helm-M-x-prefix-argument) - (integerp (car helm-M-x-prefix-argument))) - (format "%d " (car helm-M-x-prefix-argument))) - ((integerp helm-M-x-prefix-argument) - (format "%d " helm-M-x-prefix-argument))) - "M-x ") - (or collection obarray) - :test 'commandp - :requires-pattern helm-M-x-requires-pattern - :name "Emacs Commands" - :buffer "*helm M-x*" - :persistent-action (lambda (candidate) - (helm-elisp--persistent-help - candidate 'helm-describe-function)) - :persistent-help "Describe this command" - :history (or history extended-command-history) - :reverse-history helm-M-x-reverse-history - :input-history 'helm-M-x-input-history - :del-input nil - :help-message 'helm-M-x-help-message - :group 'helm-command - :keymap helm-M-x-map - :must-match t - :match-part (lambda (c) (car (split-string c))) - :fuzzy helm-M-x-fuzzy-match - :nomark t - :candidates-in-buffer t - :fc-transformer 'helm-M-x-transformer - :hist-fc-transformer 'helm-M-x-transformer-hist)) + (if sources + (helm :sources sources + :prompt (concat (cond + ((eq helm-M-x-prefix-argument '-) "- ") + ((and (consp helm-M-x-prefix-argument) + (eq (car helm-M-x-prefix-argument) 4)) "C-u ") + ((and (consp helm-M-x-prefix-argument) + (integerp (car helm-M-x-prefix-argument))) + (format "%d " (car helm-M-x-prefix-argument))) + ((integerp helm-M-x-prefix-argument) + (format "%d " helm-M-x-prefix-argument))) + "M-x ") + :buffer "*helm M-x*" + :history 'helm-M-x-input-history) + + (helm-comp-read + (concat (cond + ((eq helm-M-x-prefix-argument '-) "- ") + ((and (consp helm-M-x-prefix-argument) + (eq (car helm-M-x-prefix-argument) 4)) "C-u ") + ((and (consp helm-M-x-prefix-argument) + (integerp (car helm-M-x-prefix-argument))) + (format "%d " (car helm-M-x-prefix-argument))) + ((integerp helm-M-x-prefix-argument) + (format "%d " helm-M-x-prefix-argument))) + "M-x ") + (or collection obarray) + :test 'commandp + :requires-pattern helm-M-x-requires-pattern + :name "Emacs Commands" + :buffer "*helm M-x*" + :persistent-action (lambda (candidate) + (helm-elisp--persistent-help + candidate 'helm-describe-function)) + :persistent-help "Describe this command" + :history (or history extended-command-history) + :reverse-history helm-M-x-reverse-history + :input-history 'helm-M-x-input-history + :del-input nil + :help-message 'helm-M-x-help-message + :group 'helm-command + :keymap helm-M-x-map + :must-match t + :match-part (lambda (c) (car (split-string c))) + :fuzzy helm-M-x-fuzzy-match + :nomark t + :candidates-in-buffer t + :fc-transformer 'helm-M-x-transformer + :hist-fc-transformer 'helm-M-x-transformer-hist))) (cancel-timer tm) (setq helm--mode-line-display-prefarg nil))))) |