andre-r / centered-cursor-mode.el Goto Github PK
View Code? Open in Web Editor NEWAn emacs minor mode for smooth scrolling
License: GNU General Public License v2.0
An emacs minor mode for smooth scrolling
License: GNU General Public License v2.0
Is it possible to customize the "center" to make it maybe two thirds the page, and not half? Thanks!
To reproduce:
The bug is somewhere in the recenter animation. A workaround is to disable the animation with (setq ccm-ignored-commands '()).
As far as I can tell the line (count-lines (window-start) (point)) doesn't produce the correct result when there are collapsed lines.
I'm in the process of weeding out the causes of my input latency in Emacs, and one of the minor modes that do cause some slowdown on input, but which I cannot live without either, is centered cursor mode.
The documentation for post-command-hook suggests wrapping expensive computations in (while-no-input (redisplay) ...)
. This is not possible for functions that temporarily put Emacs in an undesirable state, but to my knowledge, ccm-position-cursor
is written well enough to only ever improve the state of Emacs, meaning canceling it halfway through when we know it will execute soon enough again should be fine.
I am currently trying this out with the following piece of advice:
(define-advice ccm-position-cursor
(:around (next) cancel-recentering-on-input)
(while-no-input (redisplay) (funcall next)))
If I'm not alone in thinking this is sensible, then it might be worth wrapping the entire body of ccm-position-cursor
to prevent individual users from having to advice it. I'll try to remember to report back with my experiences after running this for a while.
If you like it, I can submit a pull request. I just don't want to implement it properly until I've had a chance to try it out for a while.
Is it possible to use the current vertical cursor position as the locked position when entering centered-cursor-mode?
Given the windows A and B, where A is taller than B:
┌────────┐
│ ****** │ <-- Cursor skewed towards the top
│ A │
│ │
├────────┤
│ B │
└────────┘
The cursor rests on the *****
position, which is skewed towards the top rather than centered.
Expected behavior:
┌────────┐
│ │
│ ****** │ <-- Centered cursor on window A
│ │
├────────┤
│ B │
└────────┘
This is on the dev
branch
The bug happens with the previous window configuration and then opening a completion buffer (such as M-x
with Ivy/Swiper/Helm/Counsel...)
In compilation buffers, the cursor will centered when there is new output that sends it past the end of the screen. This results in only half of the compilation buffer showing output at a given time. I have set scroll-conservatively
to a large value and that seems to fix the issue.
I get mwheel-scroll-up-function is void
, also everything looks black
This is a cool package!
I'd love for recenter-top-bottom
to work when this mode is enabled. Currently, if I run end-of-buffer
to jump to the end of a buffer that's longer than one viewable page, the last line of the buffer is at the bottom of the window, with point on the last character of it.
I have recenter-positions
defined as (0.33 top bottom)
, so when I run recenter-top-bottom
, I'd expect the line that point is on to be placed 33% below the top of the window -- this is what happens if centered-cursor-mode is not activated. However, when it is activated, point and the line it is on stay pinned to the bottom of the window.
Hey there,
Just wanted to give a heads up - it looks like #25 broke backward compatibility. I was reinstalling my packages today via MELPA in Emacs 28.2, and the package stopped working.
I tried searching for an alternative version in MELPA-stable, but it seems like we only have the MELPA one, right?
(No big deal for me, though. I can keep a local version without these last changes until my distro updates Emacs to 29.1. Just wanted to let you guys know in case someone else runs into the same issue.)
Hello,
Apparently 2 new variables have been added in Emacs 29.1:
However centered-cursor-mode
does not yet support them, and I found out the hard way 😭
It seems that in Emacs 29.1:
mouse-wheel-down-alternate-event
)mouse-wheel-down-event
)As a consequence, in GUI, centered-cursor-mode
is broken.
I have found a patch in the code that seems to work for me, I will open a PR.
I'm using OSX with https://emacsformacosx.com and Fefora28 with xemacs with the centered-cursor-mode enabled and trying to select some text I noticed that the selection does not line up with my current cursor location and it also seems to jump/up down the buffer.
Is this a known side effect, or do I need to tweak anything further?
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
.
I observed the following behavior on spacemacs in evil mode:
When search+replacing with ":%s\test\bla\gc" the cursor moves to the bottom of the screen when moving through the search results.
Desired behavior:
The cursor should remain centered also when moving through search results.
I lived with CCM's default for ages and always wanted to eventually look into that weird bug where typing at the end of the document would put the cursor at the bottom of the screen, and when I move up 1 line to edit a typo it'd recenter again, and all this back and forth was rather annoying while actually writing a text where point is naturally at EOF.
Today I find out this can be disabled with a variable. And the new, faster dev branch doesn't even ship with that feautre.
To me, and I may be super biased because I suffered from the annoying ups and down for so long :), not having this functionality at all sounds like a really good idea. I wouldn't know why anyone wants centered cursor at all but not at the EOF.
So I'd like to suggest to whip up a version 2 release for the public. If you need any help @andre-r, what would you like to finish before merging dev into master?
Please allow C-l (recenter-top-bottom
) to override centered-cursor-mode
. I almost always use centered-cursor-mode
, however, at times, I need recenter-top-bottom
to more easily view a large piece of text.
If I start at the top of a buffer (one frame, one window open) and C-n down, the point moves down until line 22. Then it scrolls the buffer up, and again, on line 23, it scrolls the buffer up, and then the next C-n begins moving the point down the screen again like normal.
In Messages I have this line: "ccm-map" doesn't start with package's prefix "centered-cursor".
It works in an html files, but not an org file, so I tried adding
(add-hook 'org-mode-hook 'centered-cursor-mode)
and then M-x eval-buffer and still fails in org files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.