Open guibor opened 5 years ago
The should be fixed now, if you update from MELPA. You should have this file: elpa/lispy-20191016.1250/lispy-python.py
. That's what lp
should point to.
Thanks. I actually updated right after experiencing the issue. A silly question - for some reason when I install from MELPA lispy-python.py does not appear in the folder (even though it does if I clone the repo or at the .cache/build if installed from quelpa). Maybe this is why this isn't working for me.
Correction, the file (lispy-python.py) is actually in the right folder yet the error persists.
Here is what I had to do to make this work again - added in my python shell startup script:
lispy_dir = '/full-path-to-home/.emacs.d/.cache/quelpa/build/lispy/lispy-python.py' import imp lp = imp.load_source('lispy_python', lispy_dir)
In addition, I had to remove the following line that were run as part of python-hook: In addition, I had to remove this from my python-hooks (implementing a suggestion from https://github.com/jorgenschaefer/elpy/issues/924 in a way that would not interfere with lpy - but it looks like it does interfere somehow, even though elpy only uses python-shell-send-string-no-output)
(defun print-python-blocks () (interactive)
(defun python-shell-send-string2 (string &optional process msg) "Send STRING to inferior Python PROCESS. When optional argument MSG is non-nil, forces display of a user-friendly message if there's no process running; defaults to t when called interactively." (interactive (list (read-string "Python command: ") nil t)) (let ((process (or process (python-shell-get-process-or-error msg)))) (if (string-match ".\n+." string) ;Multiline. (let ((temp-file-name (python-shell--save-temp-file string)) (file-name (or (buffer-file-name) temp-file-name))) (python-shell-send-file file-name process temp-file-name t)) (comint-send-string process string) (when (or (not (string-match "\n\'" string)) (string-match "\n[ \t].\n?\'" string)) (comint-send-string process "\n")))))
(defun python-shell-send-string-no-output (string &optional process)
"Send STRING to PROCESS and inhibit output.
Return the output."
(let ((process (or process (python-shell-get-process-or-error)))
(comint-preoutput-filter-functions
'(python-shell-output-filter))
(python-shell-output-filter-in-progress t)
(inhibit-quit t))
(or
(with-local-quit
(python-shell-send-string2 string process)
(while python-shell-output-filter-in-progress
;; python-shell-output-filter' takes care of setting ;;
python-shell-output-filter-in-progress' to NIL after it
;; detects end of output.
(accept-process-output process))
(prog1
python-shell-output-filter-buffer
(setq python-shell-output-filter-buffer nil)))
(with-current-buffer (process-buffer process)
(comint-interrupt-subjob)))))
(defun python-shell-append-to-output (string) (let ((buffer (current-buffer))) (set-buffer (process-buffer (python-shell-get-process))) (let ((oldpoint (point))) (goto-char (process-mark (python-shell-get-process))) (insert string) (set-marker (process-mark (python-shell-get-process)) (point)) (goto-char oldpoint)) (set-buffer buffer)))
(defadvice python-shell-send-string (around advice-python-shell-send-string activate) (interactive) (let ((append-string1 (if (string-match "import codecs, os;__pyfile = codecs.open.$" string) (replace-match "" nil nil string) string)) (append-string2 (if (string-match "^# -\- coding: utf-8 -\*-\n$" append-string1) (replace-match "" nil nil append-string1) append-string1)) (append-string (if (string-match "^\n*$" append-string2) (replace-match "" nil nil append-string2) append-string2))) (python-shell-append-to-output (concat (string-trim-right append-string) "\n"))) (if (called-interactively-p 'any) (call-interactively (ad-get-orig-definition 'python-shell-send-string)) ad-do-it))
)
1==1 ---> True printed in minibuffer a =1 ---> Crashes shell
I get NameError: name ’lp’ is not defined
and then the shell becomes read-only