Subject: Re: bug#18244: 24.3.92; Error with semantic-mode when python buffers are present.

From: Thierry Volpiatto <[email-masked]>
Date: Mon, 18 May 2015 06:31:50 +0200

Thierry Volpiatto <[email-masked]> writes:

> Stefan Monnier <[email-masked]> writes:
>
>>> Remove the let-binding completely and use only:
>>
>>> (set (make-local-variable 'python-shell-interpreter) python-shell-interpreter)
>>> (set (make-local-variable 'python-shell-interpreter-args) python-shell-interpreter-args)
>>
>> I can't see why that would help.  This removes let-bindings of `args'
>> and `interpreter' but these vars are never made buffer-local
>> (hopefully), so the warning can't be about these vars being made
>> buffer-local while they're let-bound.
>
> Indeed yes, I will have another look (more carefully this time).

I see this have not been fixed, still have warnings about
python-shell-interpreter and python-shell-interpreter-args
made local while let-bound when opening a python file.
Using the following patch fix the problem, but as I am not familiar with
pyhon.el, please review.

Changes from HEAD to working tree
1 file changed, 6 insertions(+), 18 deletions(-)
 lisp/progmodes/python.el | 24 ++++++------------------

	Modified   lisp/progmodes/python.el
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 4b0a028..1b4cf2f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2496,15 +2496,8 @@ initialization of the interpreter via `python-shell-setup-codes'
 variable.
 
 \(Type \\[describe-mode] in the process buffer for a list of commands.)"
-  (let ((interpreter python-shell-interpreter)
-        (args python-shell-interpreter-args))
-    (when python-shell--parent-buffer
-      (python-util-clone-local-variables python-shell--parent-buffer))
-    ;; Users can override default values for these vars when calling
-    ;; `run-python'.  This ensures new values let-bound in
-    ;; `python-shell-make-comint' are locally set.
-    (set (make-local-variable 'python-shell-interpreter) interpreter)
-    (set (make-local-variable 'python-shell-interpreter-args) args))
+  (when python-shell--parent-buffer
+    (python-util-clone-local-variables python-shell--parent-buffer))
   (set (make-local-variable 'python-shell--prompt-calculated-input-regexp) nil)
   (set (make-local-variable 'python-shell--prompt-calculated-output-regexp) nil)
   (python-shell-prompt-set-calculated-regexps)
@@ -2553,16 +2546,11 @@ killed."
                (buffer (apply #'make-comint-in-buffer proc-name proc-buffer-name
                               interpreter nil args))
                (python-shell--parent-buffer (current-buffer))
-               (process (get-buffer-process buffer))
-               ;; As the user may have overridden default values for
-               ;; these vars on `run-python', let-binding them allows
-               ;; to have the new right values in all setup code
-               ;; that's is done in `inferior-python-mode', which is
-               ;; important, especially for prompt detection.
-               (python-shell-interpreter interpreter)
-               (python-shell-interpreter-args
-                (mapconcat #'identity args " ")))
+               (process (get-buffer-process buffer)))
           (with-current-buffer buffer
+            (set (make-local-variable 'python-shell-interpreter) interpreter)
+            (set (make-local-variable 'python-shell-interpreter-args)
+                 (mapconcat #'identity args " "))
             (inferior-python-mode))
           (when show (display-buffer buffer))
           (and internal (set-process-query-on-exit-flag process nil))))

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997