0

I experience strange behaviour when using python-mode. When sending characters to the shell using C-c C-e, the first string works well. After that, the characters start repeating, in a manner that is best understood by looking at the screenshot below. Now what is also strange is that this behaviour is also present in the minibar.

If I start emacs with emacs -q this doesn't happen. I'm looking to find what mode or setting is causing this, but I'm not knowledgeable enough to guess where to look.

The minor modes that are switched on are these:

Async-Bytecomp-Package 
Auto-Composition
Auto-Compression 
Auto-Encryption 
Blink-Cursor 
Company-Quickhelp
Company-Quickhelp-Local 
Counsel 
Counsel-Projectile 
Delete-Selection
Display-Line-Numbers 
Doom-Modeline 
Eldoc 
Electric-Indent
File-Name-Shadow 
Font-Lock 
Global-Eldoc 
Global-Font-Lock
Global-Git-Commit 
Global-Magit-File 
Ido-Everywhere 
Ivy 
Line-Number
Magit-Auto-Revert 
Mouse-Wheel 
Org-Roam 
Override-Global 
Projectile
Pyvenv Pyvenv-Tracking 
Recentf 
Shell-Dirtrack 
Tooltip 
Transient-Mark
Which-Key 
Window-Numbering

The relevant configuration I guess in my init.el

(use-package python-mode
  :ensure t
  :custom
  (python-shell-interpreter "ipython3")

If I use python for interpreter, this doesn't happen, which leads me to believe there is something wrong with the regexes used for determining the prompt. However, why does the minibar show this as well? Perhaps something else with the code that drives the inferior mode?

I would be grateful and will accept some pointers from someone that understands a bit better how this works, a plausible cause and explanation for this behaviour.

enter image description here

4
  • 1
    Add (setq python-shell-interpreter-args "-i --simple-prompt") to your configuration and see if same behaviour. – Ian Feb 18 at 13:22
  • Thanks, I tried this, and it does solve this problem. However, now the code doesn't show in the output at all, and interestingly the result numbers jump a bit. Anyway, that's a different problem. I would be happy to accept your solution if you post it as an answer, particularly if you could enlighten me a bit on what this changes. – Gijs Feb 18 at 15:09
  • One more question: do you really need python-mode (external package) or just simply the built-in python package (these are different packages; for the built-in you just need to write use-package python ...., without -mode. – Ian Feb 19 at 14:10
  • You are right again, I think I've used the external one, and the internal one seems to work better. Thanks a lot! \ – Gijs Feb 19 at 15:42
1

Two observations related to your configuration:

a) You started with the external package python-mode which may not be what you want. Instead, try using the internal package python this way:

(use-package python
     :ensure nil     ;; built-in package
     ;; the rest of your configuration) 

b) To have ipython correctly working, you need to add these lines below to your config:

(setq python-shell-interpreter "ipython3"
        python-shell-interpreter-args "-i --simple-prompt")

This setting is needed beginning with version 5 of ipython, as suggested here.

1
  • Thanks for your help. The python-mode package is a bit confusing in it's name. – Gijs Feb 21 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.