Skip to content
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

Improve counsel-M-x-transformer key lookup #1534

Merged
merged 3 commits into from Apr 23, 2018

Conversation

@basil-conto
Copy link
Collaborator

commented Apr 23, 2018

Issue

counsel-M-x-transformer unconditionally replaces C-x6 with F2 in the key description, without checking that the latter is still a valid binding.

Recipe

  1. make plain
  2. (global-set-key [f2] #'ignore)
  3. C-j
  4. M-x2C-command
    • Expected annotation: C-x6
      Screenshot after
    • Actual annotation: F2
      Screenshot before

Performance

Compared to the incumbent counsel-M-x-transformer, the final version in this PR is up to twice as fast and never slower, regardless of C-x6 replacement. The key-description -> kbd round trip, by contrast, is up to twice as slow as the incumbent. I think this justifies the only slight increase in algorithmic complexity.

basil-conto added 3 commits Apr 23, 2018
Fix spurious counsel-M-x-transformer bindings
counsel.el (counsel-M-x-transformer):
Only replace C-x 6 with <f2> when their definitions are equal.
counsel.el: (counsel-M-x-transformer): Optimise I
Reduce number of strings created.
counsel.el: (counsel-M-x-transformer): Optimise II
Avoid the key-description -> kbd round trip.

@basil-conto basil-conto force-pushed the basil-conto:blc/lookup-key branch to 5ac2fd4 Apr 23, 2018

@basil-conto

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 23, 2018

Compared to the incumbent counsel-M-x-transformer, the final version in this PR is up to twice as fast and never slower, regardless of C-x6 replacement. The key-description -> kbd round trip, by contrast, is up to twice as slow as the incumbent. I think this justifies the only slight increase in algorithmic complexity.

Of course, an even simpler approach would be to get rid of the C-x6 replacement, but I assume you still want that. :)

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Apr 23, 2018

I assume you still want that. :)

Correctly assumed:)

@abo-abo abo-abo merged commit 5ac2fd4 into abo-abo:master Apr 23, 2018

1 of 2 checks passed

continuous-integration/travis-ci/push The Travis CI build is in progress
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@abo-abo

This comment has been minimized.

Copy link
Owner

commented Apr 23, 2018

Thanks.

@basil-conto basil-conto deleted the basil-conto:blc/lookup-key branch Apr 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.