unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* :align-to space spec and line wrap
@ 2023-04-24 19:23 Qiantan Hong
  2023-04-25  7:22 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Qiantan Hong @ 2023-04-24 19:23 UTC (permalink / raw)
  To: emacs-devel@gnu.org

Hi,

I use the :align-to space spec to right align texts, like this:

(defun k-insert-fill-right (string)
  ;; More correct than `k-fill-right' in some cases, respect current
  ;; buffer settings (e.g. invisibility spec)
  (let ((from (point)))
    (insert " " string)
    (save-restriction
      (narrow-to-region (1+ from) (point))
      (let ((width (car (buffer-text-pixel-size))))
        (widen)
        (put-text-property from (1+ from)
                           'display
                           `(space :align-to (- right-fringe (,width))))))
    nil))

It works when there is no line wrap. However, when there is line wrap,
the space width shrink to zero rather than fill to (- right-fringe
(,width)) position on the new line. Seem that the width calculation
does not take line wrap into account. Is this intended? Is the
behavior that align to the right position on the new line possible to
implement?

I'm on GNU Emacs 29.0.50.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-30 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-24 19:23 :align-to space spec and line wrap Qiantan Hong
2023-04-25  7:22 ` Eli Zaretskii
2023-04-30 10:48   ` Qiantan Hong
2023-04-30 11:29     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).