olivetti icon indicating copy to clipboard operation
olivetti copied to clipboard

Styiling olivetti's margins?

Open bradmont opened this issue 4 months ago • 5 comments

Hey, I've been building a minor mode that emulates a paginated word processor type view on top of olivetti mode, you can see it here. I've tried everything I can think of to get my page break overlays to extend into the margins olivetti is producing. Can you give me any hints on how I might go about getting some text in there that I can assign a background to?

Love the package by the way. :)

bradmont avatar Dec 05 '25 04:12 bradmont

Cool idea!

I've had a quick look at your code and I think this might be the problem:

https://github.com/bradmont/page-view/blob/master/page_view.el#L244-L247

Here you're adding a display property of window-text-width, which doesn't include the width of the margins or fringes. I think you want window-total-width. But given you're working with display overlays it might be better to work in pixel sizes.

Let me know how you go!

rnkn avatar Dec 05 '25 04:12 rnkn

Yeah, I think the overall problem is that overlays apply to text in the buffer, which is limited to what is within the editable part of the window. Increasing the width like that, the overlay just gets truncated and it doesn't make a difference. I tried to figure out how to get text to display in the margins, following these docs, which I have in my debug code but without success, the overlay just displays in the body area, and pushes the content text over to compensate.

Have you ever tried to display anything in the margins in olivetti? Are they somehow different or modified from emacs native margins? In my digging around, I tried setting left-margin-width and right-margin-width interactively, but it didn't change the way olivetti displayed.

bradmont avatar Dec 05 '25 14:12 bradmont

I think you might have to put some text in the margin then put a display property on it to put a grey block the same width as the margin.

I redisplay some text in the margins here:

  • https://github.com/rnkn/fountain-mode/blob/master/fountain-mode.el#L3735-L3749
  • https://github.com/rnkn/fountain-mode/blob/master/fountain-mode.el#L3651-L3669

rnkn avatar Dec 07 '25 08:12 rnkn

Thank you, this was exactly what I needed! I've got the pagebreaks working full-width now! :)

bradmont avatar Dec 09 '25 02:12 bradmont

Brilliant! Can’t wait to see it!

rnkn avatar Dec 09 '25 02:12 rnkn

Hey I just pushed it to GitHub with an update demo screen cast if you want to see how it's looking. I'll close this issue too. Thanks for the help, if you don't mind I might wander back and pick your mind about some things you've done in fountain mode some time. :)

bradmont avatar Dec 10 '25 18:12 bradmont

Wow this is so cool! I will definitely be using this.

Yeah, ping me any time.

rnkn avatar Dec 11 '25 00:12 rnkn

Cool! It's still rough around the edges but I'll gradually polish it as I use it too. :) Let me know if you have feedback.

bradmont avatar Dec 11 '25 02:12 bradmont