reddit / emacs

Is it possible to center only specific portions of a buffer?

rfeynman42 · 2022-02-01 06:14
Is it in any way doable to vary the margin width (as I believe this is how packages like `olivetti-mode` actually accomplish centering of buffets) for only certain parts of the buffer? The main use cases I was thinking of are purely aesthetic: - a banner image on top of centered text in a buffer (a la certain [Notion notes like this](https://gdm-catalog-fmapi-prod.imgix.net/ProductScreenshot/e79f36d0-6719-4be7-9cdd-375b15c3aa33.png?ixlib=react-9.0.3&ch=Width%2CDPR&auto=format&h=auto&w=auto)), which I thought (in my limited elisp experience) might be achievable via `(put-image)` and somehow not centering only the first line of the buffer. - centering quotes or LaTeX align blocks inside Org documents I'm curious as to whether this is even possible, although I'm entirely open to any other ways of trying to implement this that don't involve varying margin lengths throughout a buffer.
[deleted] · 2022-02-01 11:09
[deleted]
00-11 · 2022-02-01 16:25
You have these commands (from `text-mode.el`): `center-line` , `center-paragraph`, `center-region`.
rfeynman42 · 2022-02-01 17:13
Those aren't exactly ideal, since I'd rather it not actually edit the text but just *appear* centered.
00-11 · 2022-02-01 18:28
(Now you know your question wasn't clearly expressed.)
nv-elisp · 2022-02-01 18:31
This could be achieved via overlays and display properties, but the information about each region which is to be displayed with a certain margin width needs to be stored somewhere.