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

Feature request: show key-binding when calling execute-extended-command with ivy enabled #136

Closed
brabalan opened this Issue Jun 10, 2015 · 12 comments

Comments

Projects
None yet
3 participants
@brabalan

Ivy meets all my helm needs, while feeling faster, with one small exception: when I use M-x I don't see the binding of the command suggested. I have found this to be a great way to learn bindings … Would you consider adding this to ivy?

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 10, 2015

Owner

Would you consider adding this to ivy?

Sure, just need to write a separate function ivy-M-x, similar to helm-M-x. Right now, I'm using my fork of smex. I've sent the pull request ages ago, looks like it's not getting merged.

Owner

abo-abo commented Jun 10, 2015

Would you consider adding this to ivy?

Sure, just need to write a separate function ivy-M-x, similar to helm-M-x. Right now, I'm using my fork of smex. I've sent the pull request ages ago, looks like it's not getting merged.

@brabalan

This comment has been minimized.

Show comment
Hide comment
@brabalan

brabalan Jun 10, 2015

Having an ivy-M-x would be great, but in the meantime I'll give your fork of smex a try. (A bit later). It's very nice indeed. I like how one can look-up key bindings, but it would be nice to see them displayed by default.

Having an ivy-M-x would be great, but in the meantime I'll give your fork of smex a try. (A bit later). It's very nice indeed. I like how one can look-up key bindings, but it would be nice to see them displayed by default.

abo-abo added a commit that referenced this issue Jun 10, 2015

counsel.el (counsel-M-x): New command
* counsel.el (counsel--format-function-M-x): New defun.

Re #136.
@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 10, 2015

Owner

Have a look. Let me know what's missing.

Owner

abo-abo commented Jun 10, 2015

Have a look. Let me know what's missing.

@kaushalmodi

This comment has been minimized.

Show comment
Hide comment
@kaushalmodi

kaushalmodi Jun 10, 2015

Contributor

Thanks for adding this.

Few comments from few minutes of trying it out:

  • Can you sort the entries by last used instead of sorting the commands alpha-numerically? Currently the first command I see is 2C-associate-buffer which I probably am never going to use. It would be nice to see commands in the order of most recently used to least recently used.
  • Is there a plan to enable fuzzy searching for certain commands using ivy/counsel? IMO counsel-M-x would be the first candidate to fit the bill for fuzzy searching. The reason is that many times the commands are long and it is faster to just ram in few letters from that whole command instead of remembering to hit a space after every few letters. Example: It is faster to type licdis instead of li c dis to get to list-colors-display.
Contributor

kaushalmodi commented Jun 10, 2015

Thanks for adding this.

Few comments from few minutes of trying it out:

  • Can you sort the entries by last used instead of sorting the commands alpha-numerically? Currently the first command I see is 2C-associate-buffer which I probably am never going to use. It would be nice to see commands in the order of most recently used to least recently used.
  • Is there a plan to enable fuzzy searching for certain commands using ivy/counsel? IMO counsel-M-x would be the first candidate to fit the bill for fuzzy searching. The reason is that many times the commands are long and it is faster to just ram in few letters from that whole command instead of remembering to hit a space after every few letters. Example: It is faster to type licdis instead of li c dis to get to list-colors-display.
@kaushalmodi

This comment has been minimized.

Show comment
Hide comment
@kaushalmodi

kaushalmodi Jun 10, 2015

Contributor

It would be awesome to make C-. and C-, work in this command too (referring to your recent blog post: http://oremacs.com/2015/06/08/describe-variable-tip/).

Contributor

kaushalmodi commented Jun 10, 2015

It would be awesome to make C-. and C-, work in this command too (referring to your recent blog post: http://oremacs.com/2015/06/08/describe-variable-tip/).

abo-abo added a commit that referenced this issue Jun 10, 2015

counsel.el (counsel-M-x): Piggyback on smex for sorting
* counsel.el (counsel-M-x): When smex is present, use it for sorting the
  candidates. Also use `counsel-describe-map', so that "C-." and "C-,"
  work for commands.

Re #136
@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 10, 2015

Owner

Added smex sorting and extra bindings. I haven't looked to implementing own sorting so far, since it can be expensive to sort.

I'll look into fuzzy matching without a space soon.

Owner

abo-abo commented Jun 10, 2015

Added smex sorting and extra bindings. I haven't looked to implementing own sorting so far, since it can be expensive to sort.

I'll look into fuzzy matching without a space soon.

abo-abo added a commit that referenced this issue Jun 10, 2015

Add fuzzy matching function
ivy.el (ivy--regex-fuzzy): New defun.

To enable fuzzy matching, set your `ivy-re-builders-alist' accordingly:

(setq ivy-re-builders-alist
      '((t . ivy--regex-fuzzy)))

Re #136
@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 10, 2015

Owner

Thanks, this fuzzy matcher isn't as slow as I thought it would be.
Actually it's as fast as the default for 8000 candidates.

Owner

abo-abo commented Jun 10, 2015

Thanks, this fuzzy matcher isn't as slow as I thought it would be.
Actually it's as fast as the default for 8000 candidates.

@brabalan

This comment has been minimized.

Show comment
Hide comment
@brabalan

brabalan Jun 11, 2015

This is great, thanks a lot!

This is great, thanks a lot!

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 12, 2015

Owner

You're welcome.

Owner

abo-abo commented Jun 12, 2015

You're welcome.

@abo-abo abo-abo closed this Jun 12, 2015

@kaushalmodi

This comment has been minimized.

Show comment
Hide comment
@kaushalmodi

kaushalmodi Jun 15, 2015

Contributor

The "recently used commands" cache stays stale until smex is called. No matter which command I execute using counsel-M-x, the first option in the command list stays the same, until I execute smex. So we also need to update the smex cache with each execution of counsel-M-x.

Contributor

kaushalmodi commented Jun 15, 2015

The "recently used commands" cache stays stale until smex is called. No matter which command I execute using counsel-M-x, the first option in the command list stays the same, until I execute smex. So we also need to update the smex cache with each execution of counsel-M-x.

@kaushalmodi

This comment has been minimized.

Show comment
Hide comment
@kaushalmodi

kaushalmodi Jun 15, 2015

Contributor

It was simply missing an smex-rank call:

(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 ((ivy-format-function #'counsel--format-function-M-x)
        (cands obarray)
        (pred 'commandp)
        (sort t))
    (when (or (featurep 'smex)
              (package-installed-p 'smex))
      (require 'smex)
      (unless smex-initialized-p
        (smex-initialize))
      (smex-detect-new-commands)
      (smex-update)
      (setq cands smex-ido-cache)
      (setq pred nil)
      (setq sort nil))
    (ivy-read "M-x " cands
              :predicate pred
              :require-match t
              :history 'extended-command-history
              :action (lambda (cmd)
                        (smex-rank (intern cmd)) ; <-- FIX
                        (execute-extended-command current-prefix-arg cmd))
              :sort sort
              :keymap counsel-describe-map
              :initial-input initial-input)))
Contributor

kaushalmodi commented Jun 15, 2015

It was simply missing an smex-rank call:

(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 ((ivy-format-function #'counsel--format-function-M-x)
        (cands obarray)
        (pred 'commandp)
        (sort t))
    (when (or (featurep 'smex)
              (package-installed-p 'smex))
      (require 'smex)
      (unless smex-initialized-p
        (smex-initialize))
      (smex-detect-new-commands)
      (smex-update)
      (setq cands smex-ido-cache)
      (setq pred nil)
      (setq sort nil))
    (ivy-read "M-x " cands
              :predicate pred
              :require-match t
              :history 'extended-command-history
              :action (lambda (cmd)
                        (smex-rank (intern cmd)) ; <-- FIX
                        (execute-extended-command current-prefix-arg cmd))
              :sort sort
              :keymap counsel-describe-map
              :initial-input initial-input)))

abo-abo added a commit that referenced this issue Jun 16, 2015

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 16, 2015

Owner

@kaushalmodi, thanks. But I think intern isn't necessary.

Owner

abo-abo commented Jun 16, 2015

@kaushalmodi, thanks. But I think intern isn't necessary.

abo-abo added a commit that referenced this issue Jun 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment