Git Product home page Git Product logo

Comments (10)

joostkremers avatar joostkremers commented on July 17, 2024 1

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.

joostkremers avatar joostkremers commented on July 17, 2024

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.

archiif avatar archiif commented on July 17, 2024

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.

joostkremers avatar joostkremers commented on July 17, 2024

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.

archiif avatar archiif commented on July 17, 2024


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.

joostkremers avatar joostkremers commented on July 17, 2024

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.

archiif avatar archiif commented on July 17, 2024

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.

joostkremers avatar joostkremers commented on July 17, 2024

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.

joostkremers avatar joostkremers commented on July 17, 2024

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.

joostkremers avatar joostkremers commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.