]> git.eshelyaron.com Git - emacs.git/commitdiff
Improved completion support when in [i]pdb
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:31 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:31 +0000 (00:03 -0300)
`python-shell-completion--do-completion-at-point' has been modified in
order to support different completion contexts easily.

New vars:
 + python-shell-completion-pdb-string-code

lisp/progmodes/python.el

index 401d9fd049514c10d69f7e872bc12767a4dada48..b4d388eb41dd68433dfc852ac8816883970914f2 100644 (file)
@@ -1609,6 +1609,13 @@ and use the following as the value of this variable:
   :group 'python
   :safe 'stringp)
 
+(defcustom python-shell-completion-pdb-string-code
+  "';'.join(globals().keys() + locals().keys())"
+  "Python code used to get completions separated by semicolons for [i]pdb."
+  :type 'string
+  :group 'python
+  :safe 'stringp)
+
 (defvar python-shell-completion-original-window-configuration nil)
 
 (defun python-shell-completion--get-completions (input process completion-code)
@@ -1628,14 +1635,20 @@ completions on the current context."
                  (buffer-substring (point-at-bol) (point)) nil nil))
           (input (substring-no-properties
                   (or (comint-word (current-word)) "") nil nil))
-          (completions
-           (if (and (> (length python-shell-completion-module-string-code) 0)
+          (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))))
+                   python-shell-completion-pdb-string-code)
+                  ((and (> (length python-shell-completion-module-string-code) 0)
                     (string-match "^\\(from\\|import\\)[ \t]" line))
-               (python-shell-completion--get-completions
-                line process python-shell-completion-module-string-code)
-             (and (> (length input) 0)
-                  (python-shell-completion--get-completions
-                   input process python-shell-completion-string-code))))
+                   python-shell-completion-module-string-code)
+                  (t python-shell-completion-string-code)))
+           (completions
+            (and (> (length input) 0)
+                 (python-shell-completion--get-completions line process completion-code)))
           (completion (when completions
                         (try-completion input completions))))
       (cond ((eq completion t)