[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Horizontal centering in the display engine
From: |
martin rudalics |
Subject: |
Re: Horizontal centering in the display engine |
Date: |
Wed, 14 Apr 2021 10:28:07 +0200 |
> The behavior I want is what's described here:
> https://en.wikipedia.org/wiki/Typographic_alignment#Centered
I think the below should do most of what's needed.
(defun center-after-text-change (begin end _length)
"..."
(save-excursion
(let ((from (progn (goto-char begin) (line-beginning-position)))
(to (progn (goto-char end) (line-beginning-position 2))))
(center-region from to))))
(defun center-after-window-change (window)
"..."
(with-current-buffer (window-buffer window)
(setq fill-column (window-body-width window))
(center-region (window-start window) (window-end window))))
(with-current-buffer (get-buffer-create "*text*")
(add-hook 'after-change-functions #'center-after-text-change 0 t)
(add-hook 'window-state-change-functions #'center-after-window-change 0 t))
(switch-to-buffer "*text*")
But if you insist on handling variable-pitch text, things will get
expensive.
martin
- Re: Horizontal centering in the display engine, (continued)
- Re: Horizontal centering in the display engine, Eli Zaretskii, 2021/04/13
- 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 <=
Re: Horizontal centering in the display engine, Paul W. Rankin, 2021/04/15