Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs: remove __PYTHON_EL_eval message

Tags:

emacs

Can Someone help me to remove the " __PYTHON_EL_eval..." message when I use run-python in Emacs?

name = "Jack"
print(f"Hello {name}")

Inferior Python Output:

__PYTHON_EL_eval("name = \"Jack\"\nprint(f\"Hello {name}\")", "/Users/Shared/ej1.py") Hello Jack
like image 849
tomas Avatar asked Jun 30 '26 17:06

tomas


1 Answers

This is a hack, but it worked for me:

(defun python-comint-filter (output)
  (let* ((regexp "^.*__PYTHON_EL_\\(.*\\)\\(.*\\)[[:space:]]*$")
         (lines (split-string output "\n"))
         (filtered-lines (remove-if (lambda (line)
                                      (or (string-match-p regexp line)
                                          (string-match-p "^\\s-*$" line))) 
                                    lines)))

    (if (equal (length lines) (length filtered-lines))
        output
      (mapconcat 'identity filtered-lines "\n"))))

and

(add-hook 'comint-preoutput-filter-functions 'python-comint-filter)

like image 164
guibor Avatar answered Jul 02 '26 07:07

guibor