all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: right aligning a string, using display (space :align-to
Date: Sat, 21 Oct 2023 09:35:38 +0300	[thread overview]
Message-ID: <83jzrgscsl.fsf@gnu.org> (raw)
In-Reply-To: <f47d79a6-0d57-4baa-aac3-089b67a3bc06@riseup.net> (martianhiatus@riseup.net)

> Date: Fri, 20 Oct 2023 22:05:40 +0200
> From: martianhiatus@riseup.net
> 
> (pls cc me so i can easily respond / quote)

That's not how newsgroups work: the response goes to the newsgroup.

> > You assume that string-pixel-width takes text-scaling into account?  I
> > don't think it does; you should use window-text-pixel-size or
> > buffer-text-pixel-size instead.  That's because text-scaling is a
> > buffer-local feature, and string-pixel-width is not told which buffer
> > you have in mind.
> 
> I'm just asking for any help i can get regarding how to right-align a string in a way that isn't broken by text-scaling. i don't know how to go about it.
> 
> i'm only using string-pixel-width because i thought i needed to subtract it from "right" in the pixel-width spec, as quoted previously. i don't see how the window or buffer functions can help with that that, as i'd have to subtract my string's pixel width from them, so they'd need to replace "right", rather than my string width calculation, it seems to me. perhaps you had in mind another way to use them, but didn't say.

You didn't say enough about your code for me to know that
window-text-pixel-size is not going to help.  If so, another
possibility is to multiply the value returned by string-pixel-width by
the ratio

  (/ (float (default-font-width)) (frame-char-width))

which should scale the string width according to text-scale-mode.



  reply	other threads:[~2023-10-21  6:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 20:05 right aligning a string, using display (space :align-to martianhiatus
2023-10-21  6:35 ` Eli Zaretskii [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-10-20 16:06 martianhiatus
2023-10-20 18:06 ` Eli Zaretskii
2023-10-19 18:05 martianhiatus
2023-10-20  6:41 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83jzrgscsl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.