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

* counsel.el: fix counsel failure with python-mode.el #2993

Merged
merged 1 commit into from
Sep 23, 2022
Merged

* counsel.el: fix counsel failure with python-mode.el #2993

merged 1 commit into from
Sep 23, 2022

Conversation

temyurchenko
Copy link
Contributor

Problem: counsel-imenu fails in python buffers with python-mode
from python-mode.el enabled.

Context: There is an emacs builtin python-mode and some others, also
named python-mode. There is also a hard-coded call to
python-imenu-create-flat-index function in counsel.el. This call
is guarded by checking that the current mode's symbol is
''python-mode. The issue is, both the builtin mode and the
python-mode.el modes use that symbol.

Solution: since guarding the mode symbol is insufficient, let's check
if the function we want to use is bound.

fixes #2992

Copy link
Collaborator

@basil-conto basil-conto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just one minor issue, see below.

Problem: counsel-imenu fails in Python buffers with python-mode
    from python-mode.el enabled.

Context: There is an Emacs builtin python-mode and some others, also
    named python-mode.  There is also a hard-coded call to
    python-imenu-create-flat-index function in counsel.el.  This
    call is guarded by checking that the current major-mode is
    python-mode.  The issue is, both the built-in mode and that from
    python-mode.el are named python-mode.

Solution: Since guarding the mode symbol is insufficient, let's check
    if the function we want to use is defined.

* counsel.el (counsel--imenu-candidates): Avoid error with external
python-mode.el by checking python-imenu-create-flat-index is defined
before calling it.  Check derived-mode-p instead of major-mode.

Fixes #2992

Copyright-paperwork-exempt: yes
Copy link
Collaborator

@basil-conto basil-conto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@basil-conto basil-conto merged commit 0ca0c09 into abo-abo:master Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

python-mode.el imenu issues
2 participants