Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop emacs erc from recentering

Tags:

emacs

Emacs erc keep recentering. It is very hard to keep up with the conversations in a small buffer because of it.

I've tried the followings but none seems to work...

(erc-scrolltobottom-mode)

(require 'erc-goodies)

(setq erc-input-line-position -1)
(erc-add-scroll-to-bottom)

(add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
(add-hook 'erc-insert-post-hook 'erc-scroll-to-bottom)

Is there a way to keep erc from recentering?

like image 619
guimobob Avatar asked Jan 18 '26 06:01

guimobob


1 Answers

The issue is that Emacs (and not erc) tries to recenter the screen every time, the cursor moves out of visible portion. See the docstring of scroll-conservatively(C-hvscroll-conservativelyRET)

Scroll up to this many lines, to bring point back on screen. If point moves off-screen, redisplay will scroll by up to `scroll-conservatively' lines in order to bring point just barely onto the screen again. If that cannot be done, then redisplay recenters point as usual.

If the value is greater than 100, redisplay will never recenter point, but will always scroll just enough text to bring point into view, even if you move far away.

A value of zero means always recenter point if it moves off screen.

So setting scroll-conservatively in erc-mode-hook might do the trick

(add-to-list 'erc-mode-hook (lambda ()
                              (set (make-local-variable 'scroll-conservatively) 100)))

Actually there are a lot of ways to achieve what you want. Have a look at this section of the Emacs manual