[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Horizontal centering in the display engine
From: |
Paul W. Rankin |
Subject: |
Re: Horizontal centering in the display engine |
Date: |
Thu, 15 Apr 2021 15:13:43 +1000 |
> From: sbaugh@catern.com
> Date: Wed, 14 Apr 2021 11:25:41 -0400
>
> Yes, that makes sense. So I'm asking about how difficult it would be to
> add a new element to the :align-to expression language, one which
> specifies the width of the current line.
I apologise in advance if I've misunderstood your aims, but you can use the
line-prefix text property and compute the value of :align-to based on the line
width and the window text width:
(defun center-align-line ()
(let (line-width align-col)
(setq line-width (- (line-end-position)
(line-beginning-position)))
(setq align-col (/ (- (window-body-width) line-width)
2))
(put-text-property (line-beginning-position)
(line-end-position)
'line-prefix
`(space :align-to ,align-col))))
Achieving this dynamically is dependent upon your major mode; if you're using a
markup syntax, you could use font-lock and a regular expression, or if manually
applied you could use a text property flag.
- Re: Horizontal centering in the display engine, (continued)
- Re: Horizontal centering in the display engine, sbaugh, 2021/04/13
- Re: Horizontal centering in the display engine, Eli Zaretskii, 2021/04/14
- Re: Horizontal centering in the display engine, sbaugh, 2021/04/14
- Re: Horizontal centering in the display engine, Yuan Fu, 2021/04/14
- Re: Horizontal centering in the display engine, Stefan Monnier, 2021/04/14
- Re: Horizontal centering in the display engine, sbaugh, 2021/04/14
- Re: Horizontal centering in the display engine, Eli Zaretskii, 2021/04/14
- Re: Horizontal centering in the display engine, sbaugh, 2021/04/14
- Re: Horizontal centering in the display engine, Eli Zaretskii, 2021/04/14
- Re: Horizontal centering in the display engine, martin rudalics, 2021/04/14
Re: Horizontal centering in the display engine,
Paul W. Rankin <=