@@ -1039,6 +1039,11 @@ that use `helm-comp-read'. See `helm-M-x' for example."
1039
1039
(symbol-help . (metadata
1040
1040
(affixation-function . helm-symbol-completion-table-affixation)
1041
1041
(category . symbol-help)))
1042
+ (command-help . (metadata
1043
+ (prefix-arg . t )
1044
+ (flags . (helm-M-x-prefix-argument))
1045
+ (affixation-function . helm-symbol-completion-table-affixation)
1046
+ (category . symbol-help)))
1042
1047
(eww-help . (metadata ; ; Emacs-30 only
1043
1048
(affixation-function . helm-completion-eww-affixation)
1044
1049
(category . eww-help)))
@@ -1106,7 +1111,7 @@ FLAGS is a list of variables to renitialize to nil when exiting or quitting.")
1106
1111
(" describe-minor-mode" . symbol-help)
1107
1112
(" where-is" . symbol-help)
1108
1113
(" execute-extended-command" . symbol-help)
1109
- (" execute-extended-command-for-buffer" . symbol -help)
1114
+ (" execute-extended-command-for-buffer" . command -help)
1110
1115
(" info-lookup-symbol" . symbol-help)
1111
1116
(" Info-goto-emacs-command-node" . symbol-help)
1112
1117
(" find-library" . library)
@@ -1506,7 +1511,7 @@ dynamically otherwise use `helm-completing-read-default-2'."
1506
1511
metadata 'display-sort-function )
1507
1512
(lambda (candidates )
1508
1513
(sort candidates #'helm-generic-sort-fn )))))
1509
- popup-info flags)
1514
+ popup-info flags pref-arg keymap )
1510
1515
(helm-aif (and (null category)
1511
1516
(assoc-default name helm-completing-read-command-categories))
1512
1517
(setq metadata `(metadata (category . , it ))
@@ -1518,54 +1523,89 @@ dynamically otherwise use `helm-completing-read-default-2'."
1518
1523
(setq metadata it)
1519
1524
(setq afun (completion-metadata-get metadata 'annotation-function )
1520
1525
afix (completion-metadata-get metadata 'affixation-function )
1526
+ pref-arg (completion-metadata-get metadata 'prefix-arg )
1521
1527
popup-info (completion-metadata-get metadata 'popup-info-function )
1522
1528
flags (completion-metadata-get metadata 'flags ))))
1529
+ (setq keymap (if pref-arg
1530
+ (let ((map (make-sparse-keymap )))
1531
+ (set-keymap-parent map helm-comp-read-map)
1532
+ (define-key map (kbd " C-u" ) 'helm-M-x-universal-argument )
1533
+ map)
1534
+ helm-comp-read-map)
1535
+ prompt (if pref-arg
1536
+ (concat (helm-acase helm-M-x-prefix-argument
1537
+ (- " -" )
1538
+ ((guard* (and (consp it) (car it)))
1539
+ (if (eq guard 4 ) " C-u " (format " %d " guard)))
1540
+ ((guard* (integerp it)) (format " %d " it)))
1541
+ prompt)
1542
+ prompt)
1543
+ helm--mode-line-display-prefarg pref-arg)
1544
+ (when pref-arg
1545
+ (setq helm-M-x--timer (run-at-time 1 0.1 #'helm-M-x--notify-prefix-arg ))
1546
+ (setq current-prefix-arg nil )
1547
+ (advice-add 'command-execute :around #'helm--advice-command-execute )
1548
+ ; ; Remove command-execute advice when execute-extended-command exit.
1549
+ (advice-add 'execute-extended-command :around #'helm--advice-execute-extended-command ))
1523
1550
(unwind-protect
1524
- (helm-comp-read
1525
- prompt collection
1526
- :test test
1527
- :history history
1528
- :reverse-history helm-mode-reverse-history
1529
- :input-history history
1530
- :must-match require-match
1531
- :alistp alistp
1532
- :diacritics helm-mode-ignore-diacritics
1533
- :help-message #'helm-comp-read-help-message
1534
- :name name
1535
- :requires-pattern (if (and (stringp default )
1536
- (string= default " " )
1537
- (memq require-match
1538
- '(confirm confirm-after-completion)))
1539
- 1 0 )
1540
- :fc-transformer
1541
- ; ; When afun afix and category are nil
1542
- ; ; helm-completion--decorate returns
1543
- ; ; candidates (COMPS) unmodified.
1544
- (append (list (lambda (candidates _source )
1545
- (helm-completion--decorate
1546
- (if (and sort-fn (> (length helm-pattern) 0 ))
1547
- (funcall sort-fn candidates)
1548
- candidates)
1549
- afun afix category)))
1550
- '(helm-cr-default-transformer))
1551
- :popup-info popup-info
1552
- :quit-when-no-cand (eq require-match t )
1553
- :nomark (null helm-comp-read-use-marked)
1554
- :candidates-in-buffer cands-in-buffer
1555
- :get-line (or get-line #'buffer-substring )
1556
- :exec-when-only-one exec-when-only-one
1557
- :fuzzy (eq helm-completion-style 'helm-fuzzy )
1558
- :buffer buffer
1559
- ; ; If DEF is not provided, fallback to empty string
1560
- ; ; to avoid `thing-at-point' to be appended on top of list
1561
- :default (or default " " )
1562
- ; ; Fail with special characters (e.g in gnus "nnimap+gmail:")
1563
- ; ; if regexp-quote is not used.
1564
- ; ; when init is added to history, it will be unquoted by
1565
- ; ; helm-comp-read.
1566
- :initial-input initial-input)
1551
+ (prog1
1552
+ (helm-comp-read
1553
+ prompt collection
1554
+ :test test
1555
+ :keymap keymap
1556
+ :history history
1557
+ :reverse-history helm-mode-reverse-history
1558
+ :input-history history
1559
+ :must-match require-match
1560
+ :alistp alistp
1561
+ :diacritics helm-mode-ignore-diacritics
1562
+ :help-message #'helm-comp-read-help-message
1563
+ :name name
1564
+ :requires-pattern (if (and (stringp default )
1565
+ (string= default " " )
1566
+ (memq require-match
1567
+ '(confirm confirm-after-completion)))
1568
+ 1 0 )
1569
+ :fc-transformer
1570
+ ; ; When afun afix and category are nil
1571
+ ; ; helm-completion--decorate returns
1572
+ ; ; candidates (COMPS) unmodified.
1573
+ (append (list (lambda (candidates _source )
1574
+ (helm-completion--decorate
1575
+ (if (and sort-fn (> (length helm-pattern) 0 ))
1576
+ (funcall sort-fn candidates)
1577
+ candidates)
1578
+ afun afix category)))
1579
+ '(helm-cr-default-transformer))
1580
+ :popup-info popup-info
1581
+ :quit-when-no-cand (eq require-match t )
1582
+ :nomark (null helm-comp-read-use-marked)
1583
+ :candidates-in-buffer cands-in-buffer
1584
+ :get-line (or get-line #'buffer-substring )
1585
+ :exec-when-only-one exec-when-only-one
1586
+ :fuzzy (eq helm-completion-style 'helm-fuzzy )
1587
+ :buffer buffer
1588
+ ; ; If DEF is not provided, fallback to empty string
1589
+ ; ; to avoid `thing-at-point' to be appended on top of list
1590
+ :default (or default " " )
1591
+ ; ; Fail with special characters (e.g in gnus "nnimap+gmail:")
1592
+ ; ; if regexp-quote is not used.
1593
+ ; ; when init is added to history, it will be unquoted by
1594
+ ; ; helm-comp-read.
1595
+ :initial-input initial-input)
1596
+ (when pref-arg (setq current-prefix-arg helm-current-prefix-arg)))
1597
+ (when (timerp helm-M-x--timer)
1598
+ (cancel-timer helm-M-x--timer) (setq helm-M-x--timer nil ))
1567
1599
(dolist (f flags) (set f nil )))))
1568
1600
1601
+ (defun helm--advice-command-execute (old--fn &rest args )
1602
+ (unless prefix-arg (setq prefix-arg current-prefix-arg))
1603
+ (apply old--fn args))
1604
+
1605
+ (defun helm--advice-execute-extended-command (old--fn &rest args )
1606
+ (prog1 (apply old--fn args)
1607
+ (advice-remove 'command-execute 'helm--advice-command-execute )))
1608
+
1569
1609
(defun helm-completing-read-default-2
1570
1610
(prompt collection predicate require-match
1571
1611
init hist default _inherit-input-method
0 commit comments