Comments (10)
My apologies, I think I didn't understand your question correctly. You did explain it clearly, but due to my misconception about what the problem was about, I failed to understand. 😞
With display-line-numbers-width
set, the old code behaved just like the new code, so it's expected that you don't see any difference. The only difference you would otherwise have seen is that the margins are slightly narrower, but not the offset that you would like.
I'll try and come up with a real solution. Stay tuned. 🙂
from writeroom-mode.
So is there a way to slightly offset the buffer visual position to compensate the line number's width?
Currently, no. writeroom-mode
simply uses window-total-width
to calculate the width. There doesn't seem to be a function to get the width of a window that takes the line numbers into account and there doesn't seem to be a way to get the current width of the line numbers.
I'll ask on emacs-devel
if there's a way to achieve this. Otherwise I'll have to come up with a work-around using line-number-at-pos
from writeroom-mode.
Just to make it clearer, here's an illustration of what I mean:
The green box is the text area and the red box is the line number column.
The above drawing is the how the buffer is currently centered. What I wanted is the bottom one.
Also, information on the line number width seems to be available in display-line-numbers-width
from writeroom-mode.
I just pushed an update to visual-fill-column-mode
, which should fix this issue. (writeroom-mode
uses visual-fill-column-mode
to set the window margins.) It seems I actually already took line numbers into account, but I did it incorrectly, so it never showed any effect.
Please let me know if you still run into problems.
from writeroom-mode.
I updated visual-fill-column
and I'm still experiencing the issue.
My display-line-numbers-width
is set to 4, writeroom-width
to 110 and I'm writing in a text-mode
buffer.
Can you replicate this issue?
from writeroom-mode.
I have pushed updates to visual-fill-column
and writeroom-mode
that should offset the text area slightly to the left if display-line-numbers-mode
is enabled. The exact offset is customisable, see the README for details.
from writeroom-mode.
Thanks a lot!
It works, but I had to subtract the line width by one or else the centering will be slightly off. Like this:
(setq writeroom-left-shift '((lambda () (1- display-line-numbers-width))))
I'm not really sure why that is the case.
from writeroom-mode.
Thanks a lot!
It works, but I had to subtract the line width by one or else the centering will be slightly off.
Yes, I'm noticing the same thing.
(setq writeroom-left-shift '((lambda () (1- display-line-numbers-width))))
Yes, that works, but I'm considering another approach. The space for line numbers is taken from the text area, so when you set writeroom-width
to, say, 80 and then activate display-line-numbers-mode
, you get a text area that's smaller than 80 characters. So perhaps it would make more sense to widen the text area in such a way that the right margin stays put.
from writeroom-mode.
I'm not really sure why that is the case.
It's because in the function visual-fill-column--window-max-text-width
, the line number width is subtracted from the maximum possible text width, which throws off further calculations. I'll take it out now that line numbers are taken into account in a different way.
from writeroom-mode.
I removed the option writeroom-left-shift
again and replaced it with writeroom-added-width-left
. Instead of shifting the text area, this adds columns to the left side of the text area, so that the line numbers do not reduce the area available for text, as was the case until now.
The default value of writeroom-added-width-left
is a function that adds columns for line numbers if they're being displayed. It shouldn't be necessary any more to customise it as you did before, I fixed visual-fill-column--window-max-text-width
and now the result looks good, at least on my machine.
If you do run into problems, please let me know.
from writeroom-mode.
Related Issues (20)
- Turn off continuation characters from truncate-lines? HOT 4
- Add screenshot to intro page HOT 2
- hide line number with a hook HOT 3
- how do I add a hook to w3m and eww HOT 1
- Navigating Lines Down and Up HOT 2
- add a "buffer effects" var HOT 6
- writeroom-mode-disable-hook does nothing HOT 2
- [Question] Which theme are you using in the snapshot? HOT 2
- how to auto active global-writeroom-mode when Emacs runs HOT 1
- global-writeroom-mode breaks org mode export scope HOT 3
- how to enable global-writeroom-mode when emacs starts HOT 2
- melpa error HOT 1
- no word wrap after 80 characters? HOT 1
- show actual time or clock? HOT 1
- Emacs -nw resize issue with ultrawide display HOT 4
- Vertical centering HOT 2
- Hide tab-bar-mode in writeroom-mode? HOT 2
- Error when Installing from Melpa HOT 2
- New global property alpha-background HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from writeroom-mode.