emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r117526: * lisp/progmodes/python.el (python-shell


From: Stefan Monnier
Subject: [Emacs-diffs] emacs-24 r117526: * lisp/progmodes/python.el (python-shell-completion-get-completions):
Date: Wed, 01 Oct 2014 00:41:57 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117526
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18582
committer: Stefan Monnier <address@hidden>
branch nick: emacs-24
timestamp: Tue 2014-09-30 20:41:51 -0400
message:
  * lisp/progmodes/python.el (python-shell-completion-get-completions):
  Use python-shell--prompt-calculated-input-regexp from the
  process buffer.
  Don't assume that `line' comes from the process buffer.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/python.el       python.el-20091113204419-o5vbwnq5f7feedwu-3008
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-09-30 23:00:57 +0000
+++ b/lisp/ChangeLog    2014-10-01 00:41:51 +0000
@@ -1,3 +1,10 @@
+2014-10-01  Stefan Monnier  <address@hidden>
+
+       * progmodes/python.el (python-shell-completion-get-completions):
+       Use python-shell--prompt-calculated-input-regexp from the
+       process buffer (bug#18582).
+       Don't assume that `line' comes from the process buffer.
+
 2014-09-30  Leonardo Nobrega  <address@hidden>  (tiny change)
 
        * progmodes/python.el (python-fill-paren): Don't inf-loop at EOB

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2014-09-30 23:00:57 +0000
+++ b/lisp/progmodes/python.el  2014-10-01 00:41:51 +0000
@@ -2687,39 +2687,38 @@
 (defun python-shell-completion-get-completions (process line input)
   "Do completion at point for PROCESS.
 LINE is used to detect the context on how to complete given INPUT."
-  (let* ((prompt
-          ;; Get last prompt of the inferior process buffer (this
-          ;; intentionally avoids using `comint-last-prompt' because
-          ;; of incompatibilities with Emacs 24.x).
-          (with-current-buffer (process-buffer process)
+  (with-current-buffer (process-buffer process)
+    (let* ((prompt
+            ;; Get last prompt of the inferior process buffer (this
+            ;; intentionally avoids using `comint-last-prompt' because
+            ;; of incompatibilities with Emacs 24.x).
             (save-excursion
               (buffer-substring-no-properties
-               (- (point) (length line))
+               (line-beginning-position) ;End of prompt.
                (progn
                  (re-search-backward "^")
-                 (python-util-forward-comment)
-                 (point))))))
-         (completion-code
-          ;; Check whether a prompt matches a pdb string, an import
-          ;; statement or just the standard prompt and use the
-          ;; correct python-shell-completion-*-code string
-          (cond ((and (> (length python-shell-completion-pdb-string-code) 0)
-                      (string-match
-                       (concat "^" python-shell-prompt-pdb-regexp) prompt))
-                 python-shell-completion-pdb-string-code)
-                ((string-match
-                  python-shell--prompt-calculated-input-regexp prompt)
-                 python-shell-completion-string-code)
-                (t nil)))
-         (input
-          (if (string-match
-               (python-rx (+ space) (or "from" "import") space)
-               line)
-              line
-            input)))
-    (and completion-code
-         (> (length input) 0)
-         (with-current-buffer (process-buffer process)
+                 (python-util-forward-comment) ;FIXME: Why?
+                 (point)))))
+           (completion-code
+            ;; Check whether a prompt matches a pdb string, an import
+            ;; statement or just the standard prompt and use the
+            ;; correct python-shell-completion-*-code string
+            (cond ((and (> (length python-shell-completion-pdb-string-code) 0)
+                        (string-match
+                         (concat "^" python-shell-prompt-pdb-regexp) prompt))
+                   python-shell-completion-pdb-string-code)
+                  ((string-match
+                    python-shell--prompt-calculated-input-regexp prompt)
+                   python-shell-completion-string-code)
+                  (t nil)))
+           (input
+            (if (string-match
+                 (python-rx (+ space) (or "from" "import") space)
+                 line)
+                line
+              input)))
+      (and completion-code
+           (> (length input) 0)
            (let ((completions
                   (python-util-strip-string
                    (python-shell-send-string-no-output


reply via email to

[Prev in Thread] Current Thread [Next in Thread]