this post was submitted on 28 Nov 2023
2 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

Hi, basically it is working well but I want to remove repetitive msg when evaluated to REPL.

for instance, when below code

nums = [1, 2, 3, 4, 5]
def double(x): return x * 2
list(map(double, nums))

is evaluated by C-c C-c

>>> 
__PYTHON_EL_eval("nums = [1, 2, 3, 4, 5]\ndef double(x): return x * 2\nlist(map(double, nums))", "/Users/darren/Work/ace/pyth/codi/01-iterations/binary-gap.py")
[2, 4, 6, 8, 10]

Can I remove this msg?

__PYTHON_EL_eval("nums = [1, 2, 3, 4, 5]\ndef double(x): return x * 2\nlist(map(double, nums))", "/Users/darren/Work/ace/pyth/codi/01-iterations/binary-gap.py")

So it just shows like

>>> 
[2, 4, 6, 8, 10]

Thanks in advance!

you are viewing a single comment's thread
view the rest of the comments
[–] Patient_Chance_3795@alien.top 1 points 1 year ago

Some answers here
https://stackoverflow.com/questions/75103221/emacs-remove-python-el-eval-message

(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"))))