syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Disable scroll-margin for (some) comint mode buffers #3098

Closed rakyi closed 8 years ago

rakyi commented 8 years ago

It doesn't make much sense to have a scroll-margin in shell (breaks top for example) or erc, so I think it should be disabled there. I don't know if there are some comint mode derived modes where it makes sense to have the margin set.

darkfeline commented 8 years ago

Fix:

(add-hook 'term-mode-hook
          (lambda ()
              (set (make-local-variable 'scroll-margin) 0)))

I think term-mode is the only place where this needs to be fixed? Shell mode isn't a terminal emulator so top shouldn't run in shell mode anyway. However, things like top or vi should be able to run in term-mode; the above snippet fixes this bug (see https://github.com/syl20bnr/spacemacs/issues/3204).

I'll make a PR if I don't forget; anyone else is welcome to steal this easy fix.

TheBB commented 8 years ago

It's not just for fixing top, it's also for killing that stupid five-line gap at the bottom of the buffer when you're in a mode where you are literally always at the end.

I apply this in eshell-mode, term-mode, erc-mode, messages-buffer-mode, inferior-emacs-lisp-mode and inferior-pyhon-mode. The inferior-... modes can be covered using comint-mode instead, but the others do not derive from comint. (Shell-mode does derive from comint)

By the way, setq-local is equivalent to (set (make-local-variable ...) ...)

dsdshcym commented 8 years ago

This may not be the right place to ask this. But why do we need to set the scroll margin to 5? Is it for smooth scrolling?

nixmaniack commented 8 years ago

@dsdshcym To have some context always visible when we're hitting top/bottom of buffer.

dsdshcym commented 8 years ago

@nixmaniack Thank you for your reply! I think I'd better try to set the margin to 0 for a while to find out the differences.