   ;; Emacs 19 requires this
   (if (boundp 'comment-multi-line)
       (setq comment-multi-line nil))
-  ;; Install Imenu, only works for Emacs.
+  ;; Install Imenu if available
   (when (py-safe (require 'imenu))
-    (make-variable-buffer-local 'imenu-create-index-function)
-    (setq imenu-create-index-function
-	  (function imenu-example--create-python-index))
-    (setq imenu-generic-expression
-	  imenu-example--generic-python-expression)
+    (setq imenu-create-index-function #'py-imenu-create-index-function)
+    (setq imenu-generic-expression py-imenu-generic-expression)
     (if (fboundp 'imenu-add-to-menubar)
 	(imenu-add-to-menubar (format "%s-%s" "IM" mode-name)))
     )

     ))
  "Additional expressions to highlight in Python mode.")
(put 'python-mode 'font-lock-defaults '(python-font-lock-keywords))


(defvar imenu-example--python-show-method-args-p nil 
  "*Controls echoing of arguments of functions & methods in the imenu buffer.
When non-nil, arguments are printed.")

(make-variable-buffer-local 'py-indent-offset)

;; have to bind py-file-queue before installing the kill-emacs-hook
(defvar py-file-queue nil

  "*Function called by `py-electric-delete' when deleting forwards."
  :type 'function
  :group 'python)

(defcustom py-imenu-show-method-args-p nil 
  "*Controls echoing of arguments of functions & methods in the Imenu buffer.
When non-nil, arguments are printed."
  :type 'boolean
  :group 'python)
(make-variable-buffer-local 'py-indent-offset)

;; Not customizable
(defvar py-master-file nil
