]> git.eshelyaron.com Git - emacs.git/commitdiff
Improvements on completion code.
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:32 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:32 +0000 (00:03 -0300)
Do no complete when defining a code block (we can't do this until
finding some way of getting raw tabs to the interpreter correctly)

lisp/progmodes/python.el

index b4d388eb41dd68433dfc852ac8816883970914f2..5842dc021c61c0368c8dbb742f93b9147fe37cf7 100644 (file)
@@ -1635,20 +1635,27 @@ completions on the current context."
                  (buffer-substring (point-at-bol) (point)) nil nil))
           (input (substring-no-properties
                   (or (comint-word (current-word)) "") nil nil))
+           (prompt (buffer-substring-no-properties
+                    (overlay-start comint-last-prompt-overlay)
+                    (overlay-end comint-last-prompt-overlay)))
           (completion-code
             (cond ((and (> (length python-shell-completion-pdb-string-code) 0)
-                        (string-match python-shell-prompt-pdb-regexp
-                                      (buffer-substring-no-properties
-                                       (overlay-start comint-last-prompt-overlay)
-                                       (overlay-end comint-last-prompt-overlay))))
+                        (string-match
+                         (concat "^" python-shell-prompt-pdb-regexp) prompt))
                    python-shell-completion-pdb-string-code)
                   ((and (> (length python-shell-completion-module-string-code) 0)
-                    (string-match "^\\(from\\|import\\)[ \t]" line))
+                        (string-match
+                         (concat "^" python-shell-prompt-regexp) prompt)
+                        (string-match "^\\(from\\|import\\)[ \t]" line))
                    python-shell-completion-module-string-code)
-                  (t python-shell-completion-string-code)))
+                  ((string-match
+                    (concat "^" python-shell-prompt-regexp) prompt)
+                   python-shell-completion-string-code)
+                  (t nil)))
            (completions
-            (and (> (length input) 0)
-                 (python-shell-completion--get-completions line process completion-code)))
+            (and completion-code (> (length input) 0)
+                 (python-shell-completion--get-completions
+                  line process completion-code)))
           (completion (when completions
                         (try-completion input completions))))
       (cond ((eq completion t)
@@ -1661,19 +1668,19 @@ completions on the current context."
            ((null completion)
             (message "Can't find completion for \"%s\"" input)
             (ding)
-           nil)
-          ((not (string= input completion))
-           (progn (delete-char (- (length input)))
-                 (insert completion)
-                 t))
-          (t
-          (unless python-shell-completion-original-window-configuration
-             (setq python-shell-completion-original-window-configuration
-                 (current-window-configuration)))
-           (with-output-to-temp-buffer "*Python Completions*"
-             (display-completion-list
-              (all-completions input completions)))
-           t)))))
+             nil)
+            ((not (string= input completion))
+             (progn (delete-char (- (length input)))
+                    (insert completion)
+                    t))
+            (t
+             (unless python-shell-completion-original-window-configuration
+               (setq python-shell-completion-original-window-configuration
+                     (current-window-configuration)))
+             (with-output-to-temp-buffer "*Python Completions*"
+               (display-completion-list
+                (all-completions input completions)))
+             t)))))
 
 (defun python-shell-completion-complete-at-point ()
   "Perform completion at point in inferior Python process."