An Emacs mode for editing Python code

Windows problem with py-execute-directory

Asked by Andy Smith on 2012-10-25

Hi All,

On windows I've had to replace line 9274...

         (py-execute-directory (or (ignore-errors (file-name-directory (file-remote-p (buffer-file-name) 'localname)))(getenv "WORKON_HOME")(getenv "HOME")))

with ...

         (py-execute-directory (or (file-name-directory buffer-file-name)(getenv "WORKON_HOME")(getenv "HOME")))

i.e. the (ignore-errors .....) clause has failed on me.

Without this modification I get....
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:/cygwin/tmp/python-6060ECQ.py", line 3, in <module>
    import os; os.chdir("C:\home\andy")
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\home\x07ndy'

I'm not an elisp guru but I guess the ignore-errors clause is failing, and the 'or' is moving on to(getenv "HOME"), and some wierd escaping is happening on my home directory - "C:\home\andy".

I don't know why (buffer-file-name) is in paren. It would make sense if if buffer-file-name is a function , but buffer-file-name is a variable so doesn't need to be wrapped in parens???!! Given that, i can't see how that clause can ever work.

Take with a pinch of salt though - like i say I'm not an elisp guru by any stretch.

Cheers,

A.

Question information

Language:
English Edit question
Status:
Answered
For:
python-mode.el Edit question
Assignee:
No assignee Edit question
Last query:
2012-10-25
Last reply:
2012-10-25
Andreas Roehler (a-roehler) said : #1

Am 25.10.2012 11:11, schrieb Andy Smith:
> New question #212270 on python-mode.el:
> https://answers.launchpad.net/python-mode/+question/212270
>
>
> Hi All,
>
> On windows I've had to replace line 9274...
>
> (py-execute-directory (or (ignore-errors (file-name-directory (file-remote-p (buffer-file-name) 'localname)))(getenv "WORKON_HOME")(getenv "HOME")))
>
> with ...
>
> (py-execute-directory (or (file-name-directory buffer-file-name)(getenv "WORKON_HOME")(getenv "HOME")))
>
> i.e. the (ignore-errors .....) clause has failed on me.
>
> Without this modification I get....
>>>> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "c:/cygwin/tmp/python-6060ECQ.py", line 3, in <module>
> import os; os.chdir("C:\home\andy")
> WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\home\x07ndy'
>
> I'm not an elisp guru but I guess the ignore-errors clause is failing, and the 'or' is moving on to(getenv "HOME"), and some wierd escaping is happening on my home directory - "C:\home\andy".
>
> I don't know why (buffer-file-name) is in paren. It would make sense if if buffer-file-name is a function , but buffer-file-name is a variable so doesn't need to be wrapped in parens???!! Given that, i can't see how that clause can ever work.
>
> Take with a pinch of salt though - like i say I'm not an elisp guru by any stretch.
>
> Cheers,
>
> A.
>
>
>
>

thanks, it's here now: lp:1071374

Can you help with this problem?

Provide an answer of your own, or ask Andy Smith for more information if necessary.

To post a message you must log in.