@@ -1047,7 +1047,6 @@ that use `helm-comp-read'. See `helm-M-x' for example."
1047
1047
(category . symbol-help)))
1048
1048
(command-help . (metadata
1049
1049
(prefix-arg . t )
1050
- (flags . (helm-M-x-prefix-argument))
1051
1050
(affixation-function . helm-symbol-completion-table-affixation)
1052
1051
(category . symbol-help)))
1053
1052
(eww-help . (metadata ; ; Emacs-30 only
@@ -1550,10 +1549,13 @@ dynamically otherwise use `helm-completing-read-default-2'."
1550
1549
helm--mode-line-display-prefarg pref-arg)
1551
1550
(when pref-arg
1552
1551
(setq helm-M-x--timer (run-at-time 1 0.1 #'helm-M-x--notify-prefix-arg ))
1552
+ (add-hook 'helm-move-selection-after-hook
1553
+ #'helm-M-x--move-selection-after-hook )
1554
+ (add-hook 'helm-before-action-hook
1555
+ #'helm-M-x--before-action-hook )
1553
1556
; ; Notify C-u entered before Hitting M-[xX].
1554
1557
(setq helm-M-x-prefix-argument current-prefix-arg)
1555
1558
(setq current-prefix-arg nil )
1556
- (advice-add 'command-execute :around #'helm--advice-command-execute )
1557
1559
; ; Remove command-execute advice when execute-extended-command exit.
1558
1560
(advice-add 'execute-extended-command :around #'helm--advice-execute-extended-command ))
1559
1561
(unwind-protect
@@ -1602,13 +1604,20 @@ dynamically otherwise use `helm-completing-read-default-2'."
1602
1604
; ; when init is added to history, it will be unquoted by
1603
1605
; ; helm-comp-read.
1604
1606
:initial-input initial-input)
1605
- (when pref-arg ( setq current-prefix-arg helm-current-prefix-arg)))
1606
- ( when ( timerp helm-M-x--timer )
1607
- ( cancel-timer helm-M-x--timer) ( setq helm-M-x--timer nil ) )
1607
+ (when pref-arg
1608
+ ( advice-add 'command-execute :around # ' helm--advice-command-execute )) )
1609
+ ( helm-M-x--unwind-forms )
1608
1610
(dolist (f flags) (set f nil )))))
1609
1611
1610
1612
(defun helm--advice-command-execute (old--fn &rest args )
1611
- (unless prefix-arg (setq prefix-arg current-prefix-arg))
1613
+ (helm-M-x--unwind-forms 'done )
1614
+ ; ; `command-execute' is wrapped in a let with `prefix-arg' bound to the argument
1615
+ ; ; PREFIXARG of `execute-extended-command' so set this let-bounded `prefix-arg'
1616
+ ; ; to the value defined during helm completion. We use
1617
+ ; ; helm-M-x-prefix-argument instead of initial PREFIXARG to allow changing the
1618
+ ; ; initial prefix arg during helm completion e.g. C-u M-X foo C-u 2 foo, in
1619
+ ; ; this case the initial C-u is replaced by C-u 2.
1620
+ (setq prefix-arg (or helm-current-prefix-arg helm-M-x-prefix-argument))
1612
1621
(apply old--fn args))
1613
1622
1614
1623
(defun helm--advice-execute-extended-command (old--fn &rest args )
0 commit comments