]> git.eshelyaron.com Git - emacs.git/commitdiff
fixed CL related bytecompilation errors and set make-tree for imenu default
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:14 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:14 +0000 (00:03 -0300)
lisp/progmodes/python.el

index a582dc6db2af6a0acc7188778cfbab8fb6eb5512..860f0859b01865e3972d3f41c2187feaa4a31b1c 100644 (file)
@@ -1152,13 +1152,13 @@ run).
          (proc-buffer-name (format "*%s*" proc-name))
          (process-environment
           (if python-shell-process-environment
-              (merge 'list python-shell-process-environment
-                     process-environment 'string=)
+              (python-util-merge 'list python-shell-process-environment
+                                 process-environment 'string=)
             process-environment))
          (exec-path
           (if python-shell-exec-path
-              (merge 'list python-shell-exec-path
-                     exec-path 'string=)
+              (python-util-merge 'list python-shell-exec-path
+                                 exec-path 'string=)
             exec-path)))
     (when (not (comint-check-proc proc-buffer-name))
       (let ((cmdlist (split-string-and-unquote cmd)))
@@ -1956,7 +1956,7 @@ Interactively, prompt for symbol."
   :group 'python
   :safe 'booleanp)
 
-(defcustom python-imenu-make-tree nil
+(defcustom python-imenu-make-tree t
   "Non-nil make imenu to build a tree menu.
 Set to nil for speed."
   :type 'boolean
@@ -1992,7 +1992,8 @@ Argument PLAIN-INDEX is the calculated plain index used to build the tree."
                                      (mapconcat #'identity full-element ".")
                                      plain-index)))
              (subelement-name (car element-list))
-             (subelement-position (position subelement-name full-element))
+             (subelement-position (python-util-position
+                                   subelement-name full-element))
              (subelement-path (when subelement-position
                                 (butlast
                                  full-element
@@ -2045,10 +2046,10 @@ This tree gets built:
 Internally it uses `python-imenu-make-element-tree' to create all
 branches for each element."
 (setq python-imenu-index-alist nil)
-(mapcar (lambda (element)
-          (python-imenu-make-element-tree element element index))
-        (mapcar (lambda (element)
-                  (split-string (car element) "\\." t)) index))
+(mapc (lambda (element)
+        (python-imenu-make-element-tree element element index))
+      (mapcar (lambda (element)
+              (split-string (car element) "\\." t)) index))
 python-imenu-index-alist)
 
 (defun python-imenu-create-index ()
@@ -2194,6 +2195,29 @@ character address of the specified TYPE."
        (nth 1 ppss))
       (t nil))))
 
+\f
+;;; Utility functions
+
+;; Stolen from GNUS
+(defun python-util-merge (type list1 list2 pred)
+  "Destructively merge lists LIST1 and LIST2 to produce a new list.
+Argument TYPE is for compatibility and ignored.
+Ordering of the elements is preserved according to PRED, a `less-than'
+predicate on the elements."
+  (let ((res nil))
+    (while (and list1 list2)
+      (if (funcall pred (car list2) (car list1))
+          (push (pop list2) res)
+        (push (pop list1) res)))
+    (nconc (nreverse res) list1 list2)))
+
+(defun python-util-position (item seq)
+  "Find the first occurrence of ITEM in SEQ.
+Return the index of the matching item, or nil if not found."
+  (let ((member-result (member item seq)))
+    (when member-result
+      (- (length seq) (length member-result)))))
+
 \f
 ;;;###autoload
 (define-derived-mode python-mode fundamental-mode "Python"