Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27ee115

Browse files
committed
Removed redundant eval-when-compile.
(python-mode): Conditionalize imenu initializations to when we can safely require imenu. Under Emacs this should prevent python-mode from hosing the global value of imenu-create-index-function and messing things up for all other modes. Problem identified by Christian Egli. (py-describe-mode): py-delete-char => py-electric-backspace. Given by Christian Egli.
1 parent 456035f commit 27ee115

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

Misc/python-mode.el

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,6 @@ better alternative for finding the index.")
676676
(defvar imenu-example--python-generic-parens nil)
677677

678678

679-
;;;###autoload
680-
(eval-when-compile
681-
;; Imenu isn't used in XEmacs, so just ignore load errors
682-
(condition-case ()
683-
(progn
684-
(require 'cl)
685-
(require 'imenu))
686-
(error nil)))
687-
688679
(defun imenu-example--create-python-index ()
689680
"Python interface function for imenu package.
690681
Finds all python classes and functions/methods. Calls function
@@ -898,13 +889,16 @@ py-beep-if-tab-change\t\tring the bell if tab-width is changed"
898889
(goto-char start))
899890

900891
;; install imenu
901-
(make-variable-buffer-local 'imenu-create-index-function)
902-
(setq imenu-create-index-function
903-
(function imenu-example--create-python-index))
904-
(setq imenu-generic-expression
905-
imenu-example--generic-python-expression)
906-
(if (fboundp 'imenu-add-to-menubar)
907-
(imenu-add-to-menubar (format "%s-%s" "IM" mode-name)))
892+
(if (py-safe (require 'imenu))
893+
(progn
894+
(make-variable-buffer-local 'imenu-create-index-function)
895+
(setq imenu-create-index-function
896+
(function imenu-example--create-python-index))
897+
(setq imenu-generic-expression
898+
imenu-example--generic-python-expression)
899+
(if (fboundp 'imenu-add-to-menubar)
900+
(imenu-add-to-menubar (format "%s-%s" "IM" mode-name)))
901+
))
908902

909903
;; run the mode hook. py-mode-hook use is deprecated
910904
(if python-mode-hook
@@ -2249,7 +2243,7 @@ of some continuation line.
22492243
Primarily for entering new code:
22502244
\t\\[indent-for-tab-command]\t indent line appropriately
22512245
\t\\[py-newline-and-indent]\t insert newline, then indent
2252-
\t\\[py-delete-char]\t reduce indentation, or delete single character
2246+
\t\\[py-electric-backspace]\t reduce indentation, or delete single character
22532247
22542248
Primarily for reindenting existing code:
22552249
\t\\[py-guess-indent-offset]\t guess py-indent-offset from file content; change locally
@@ -2288,7 +2282,7 @@ indentation of the (closest code or indenting-comment) preceding
22882282
statement, or adds an extra py-indent-offset blanks if the preceding
22892283
statement has `:' as its last significant (non-whitespace and non-
22902284
comment) character. If the suggested indentation is too much, use
2291-
\\[py-delete-char] to reduce it.
2285+
\\[py-electric-backspace] to reduce it.
22922286
22932287
Continuation lines are given extra indentation. If you don't like the
22942288
suggested indentation, change it to something you do like, and Python-
@@ -2317,7 +2311,7 @@ repeatedly, and as explained above, \\[indent-for-tab-command] can't guess the b
23172311
structure you intend.
23182312
%c:indent-for-tab-command
23192313
%c:py-newline-and-indent
2320-
%c:py-delete-char
2314+
%c:py-electric-backspace
23212315
23222316
23232317
The next function may be handy when editing code you didn't write:

0 commit comments

Comments
 (0)