[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/counsel 0ca0c096f1 1/2: Fix counsel-imenu failure with
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/counsel 0ca0c096f1 1/2: Fix counsel-imenu failure with python-mode.el |
Date: |
Fri, 23 Sep 2022 06:54:49 -0400 (EDT) |
branch: externals/counsel
commit 0ca0c096f1ed6a920f3b398f743525adddb1ad61
Author: Artem Yurchenko <artemyurchenko@zoho.com>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Fix counsel-imenu failure with python-mode.el
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
---
counsel.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/counsel.el b/counsel.el
index bd1c1b5bb3..a938330d49 100644
--- a/counsel.el
+++ b/counsel.el
@@ -4692,7 +4692,6 @@ S will be of the form \"[register]: content\"."
(defvar imenu-auto-rescan-maxout)
(declare-function imenu--subalist-p "imenu")
(declare-function imenu--make-index-alist "imenu")
-(declare-function python-imenu-create-flat-index "python")
(defun counsel--imenu-candidates ()
(require 'imenu)
@@ -4704,7 +4703,8 @@ S will be of the form \"[register]: content\"."
(items (delete (assoc "*Rescan*" items) items))
(items (cond ((eq major-mode 'emacs-lisp-mode)
(counsel-imenu-categorize-functions items))
- ((eq major-mode 'python-mode)
+ ((and (derived-mode-p 'python-mode)
+ (fboundp 'python-imenu-create-flat-index))
(python-imenu-create-flat-index))
(t
items))))