Giter Club home page Giter Club logo

Comments (6)

rnkn avatar rnkn commented on May 25, 2024 1

Actually I have maybe found a workaround. If it's not too much trouble, can you test out the git branch min-margins?

from olivetti.

nchachereau avatar nchachereau commented on May 25, 2024 1

I see, thanks for the explanation. But mostly many thanks for the update, great to have this fixed! Now I can enjoy writing and taking notes in Emacs with proper margins that adjust when I open other applications 🎉

from olivetti.

rnkn avatar rnkn commented on May 25, 2024

Thanks for the report. I've noticed this too (on macOS). I'm quite sure Emacs is at fault here. With each major version, the window display code get broken a little more. I've tried very hard to get the maintainers to stop breaking the window display code but to no avail.

The most obvious pointer is that the margins are being correctly calculated upon entering full screen but not exiting, which is running the same function on the same hook. It's just that Emacs isn't provided the right values for the function to work.

Evaluating (olivetti-set-margins) does not help, so it seems the problem is not with the hook but with the function itself.

This function relies on window-total-width returning a correct result, which in this case it doesn't.

Feel free to try get the maintainers to either fix this or swoop in and prove me wrong. Either way is cool.

from olivetti.

nchachereau avatar nchachereau commented on May 25, 2024

Thanks a lot!

First of all, I tested the min-margins branch and it seems to fix the problem for me. However, even though I do not use text-scale-mode, I had the idea of trying it out because I saw references to it in your latest commits and in the code, and I get strange error messages with the min-margins branch. You might want to look into that before releasing a new version of the package.

Just another note, regarding window-total-width: trying the following code in a buffer shows that the function returns a correct result when olivetti-mode is disabled, as well as with the min-margins branch:

(defun test (&optional win-or-frame)
  (message "%s" (window-total-width)))

(add-hook 'window-size-change-functions #'test t t)

However, with master-branch olivetti-mode enabled, the functions then starts reporting erroneous numbers. So it seems master-branch olivetti-set-margins somehow fails or changes something that then causes window-total-width to fail as well. I just thought I would point this out, because then you can choose between your new branch that you describe as a "workaround" or fixing the older branch. (Even though I am aware this is maybe not the whole story, because of the way I call the function in my test, ignoring the win-or-frame argument.)

Either way, thank you for taking the time and please tell me if I can help with further tests.

from olivetti.

rnkn avatar rnkn commented on May 25, 2024

Thanks for the investigation. The issue with text-scale-mode has been fixed in that branch btw.

I understand that it seems like it should work, but it's not the full story. Olivetti is really just doing the following:

  1. resetting the window margins
  2. asking for window-total-width
  3. calculating the window margins based on that

And that's called on window-size-change-functions hook.

Which seems simple enough, but resetting the margins also calls window-size-change-functions. To prevent a loop, Emacs schedules hooks in weird ways. When exiting full screen it's scheduling the hooks incorrectly, or rather just incorrectly to what we want, hence when olivetti asks for window-total-width it's receiving the wrong value.

from olivetti.

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.