-
-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
counsel-M-x should not set last-command #891
Comments
|
That's not the behaviour I'm seeing: (global-set-key (kbd "M-x") #'counsel-M-x)
(global-set-key (kbd "C-c M-x") #'execute-extended-command)
(defun wh/report-last-command ()
(interactive)
(message "last-command: %s" last-command)) With ivy-mode disabled,
The first invocation looks like
|
I don't why results that you show happen. But I know that this bit is needed: (let ((prefix-arg current-prefix-arg))
(setq real-this-command
(setq this-command (intern cmd)))
(command-execute (intern cmd) 'record)) Here's my experience: |
Yep, I'm seeing the same as you. |
The I don't know why your function doesn't work. Patches for a fix are welcome, but let's make sure the standard functionality still works. |
I suspect the problem is that we're setting Here's one possible patch: (defun counsel-M-x (&optional initial-input)
"Ivy version of `execute-extended-command'.
Optional INITIAL-INPUT is the initial input in the minibuffer."
(interactive)
(unless initial-input
(setq initial-input (cdr (assoc this-command
ivy-initial-inputs-alist))))
(let* ((cands obarray)
(pred 'commandp)
(sort t))
(when (require 'smex nil 'noerror)
(unless smex-initialized-p
(smex-initialize))
(smex-detect-new-commands)
(smex-update)
(setq cands smex-ido-cache)
(setq pred nil)
(setq sort nil))
;; Ensure that `counsel-M-x' is never stored in `last-command',
;; for consistency with `execute-extended-command'. The :action
;; is invoked after `counsel-M-x' returns, so that isn't sufficient.
(setq this-command last-command)
(setq real-this-command real-last-command)
(ivy-read (counsel--M-x-prompt) cands
:predicate pred
:require-match t
:history 'extended-command-history
:action
(lambda (cmd)
(when (featurep 'smex)
(smex-rank (intern cmd)))
(setq this-command (intern cmd))
(setq real-this-command (intern cmd))
(let ((prefix-arg current-prefix-arg))
(command-execute (intern cmd) 'record)))
:sort sort
:keymap counsel-describe-map
:initial-input initial-input
:caller 'counsel-M-x))) Another option would be to save |
I've noticed that using
counsel-M-x
setslast-command
. This means that I can't do(if (eq this-command last-command) ...)
to see if my command is being called repeatedly.The text was updated successfully, but these errors were encountered: