andre-r / centered-cursor-mode.el

An emacs minor mode for smooth scrolling
GNU General Public License v2.0
60 stars 12 forks source link

Option to disable centering at beginning of file #11

Closed ColemanGariety closed 4 years ago

ColemanGariety commented 4 years ago

There's already an option to disable recentering at EOF, it would make a lot of sense if there were an equivalent option for centering at BOF as well. Presently, when centered-cursor-mode is enabled, it is not possible to get to the beginning of the file with PgUp.

andre-r commented 4 years ago

I normally works as expected at the start of a file. There are however some modes have own scroll-commands like Info-mode that binds Info-scroll-down to S-SPC that prevents scrolling to the top with centered-cursor-mode. But your problem doesn't sound like that. Could you give some more information, like other mode that might be intervening?

ColemanGariety commented 4 years ago

@andre-r I have C-b mapped to evil-scroll-page-up, that's probably why. What's the best way to get it to scroll all the way up?

andre-r commented 4 years ago

Try this in your init file:

(defun ccm-remap-evil-keys ()
  (when (and centered-cursor-mode evil-mode)
    ;; up is down, evil doesn't follow the convention
    (local-set-key [remap evil-scroll-page-up] 'ccm-scroll-down)
    (local-set-key [remap evil-scroll-page-down] 'ccm-scroll-up)))

(add-hook 'evil-mode-hook 'ccm-remap-evil-keys)
(add-hook 'centered-cursor-mode-hook 'ccm-remap-evil-keys)

I am working (sporadically) on improvements, including compatibility with other packages. I'll make a note for evil-mode.