jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 262 forks source link

How to keep the python shell buffer scrolling down at all times #1641

Closed CDitzel closed 5 years ago

CDitzel commented 5 years ago

I desire a behaviour where upon C-c C-c the python shell (either already open or popping up) keeps scrolling down to display the most recent content.

Currently it only does so, when it is invoked the very first time. But if i press the execution key combination again, the buffer view just remains at the current position.

Does anyone know how to enable this?

galaunay commented 5 years ago

By default, it is already supposed to do so, but only if the cursor is at the end of the buffer.

This part of the Emacs documentation mentions the variable comint-move-point-for-output which may be what you are looking for.

If so, you can set it for python interpreter buffer with something like this:

(add-hook 'inferior-python-mode-hook
          (lambda ()
            (setq comint-move-point-for-output t)))

Hope it helps.

CDitzel commented 5 years ago

thanks for your help but this does not seem to change anything oO

galaunay commented 5 years ago

So there may be something wrong here. Could you post the result of elpy-config and the way you configure elpy in your init.el (or similar) ?

In a meantime, you should be able to use this workaround to scroll to the bottom of the python interpreter every time you hit return:

(advice-add 'elpy-shell-send-region-or-buffer
            :before (lambda (&optional rest)
                      (let ((curbuf (current-buffer)))
                        (elpy-shell-switch-to-shell)
                        (goto-char (point-max))
                        (recenter -10)
                        (elpy-shell-switch-to-buffer)))
            '((name . "elpy-shell-scroll-to-bottom")))
CDitzel commented 5 years ago

it seems to work now after I restared emacs ?= thanks a lot!

xelephas commented 3 years ago

The elpy-shell-send-region-or-buffer command is very usefully for me!

Actually, I would always want this behavior just to make sure there is no strange "side effect" caused by previous script run.

Maybe It could be added to the package?