unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: hugo@heagren.com
Cc: 62606@debbugs.gnu.org
Subject: bug#62606: [PATCH] function to align mode-line elements to right
Date: Fri, 09 Jun 2023 12:03:02 -0400	[thread overview]
Message-ID: <jwv7csc7idp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <d41f7452947c09b93fa6bc86ceb3f883@heagren.com> (hugo@heagren.com's message of "Sat, 01 Apr 2023 23:27:31 +0100")

> Let's hear from others.  Stefan, Lars, any thoughts?  Does anyone else
> have any comments about this proposed feature?

FWIW, my mode-lines always tend to overflow to the right, so I wouldn't
be able to use that functionality, but I have no doubt that it would be
welcome by several users, based on some of the mode-lines I've
seen elsewhere.

Also, the code is fairly simple and self-contained, so I don't see
a good reason not to include that.

Some comments about the code below:

> +(defcustom mode-line-right-align-edge 'window
> +  "Where function `mode-line-format-right-align' should align to.
> +
> +Must be set to a symbol.  Acceptable values are:
> +- window: align to extreme right of window, regardless of margins
> +  or fringes
> +- right-fringe: align to right-fringe
> +- right-margin: align to right-margin
> +- right: synonym for right-margin (supported because this is how the
> +  display property understands this, see info node `(elisp)Specified
> +  Space'.)"

I think symbols like `right-fringe` should be enclosed in `...'
in docstrings.  Also, I see no reason to encourage the use of an alias,
so I'd drop either `right-margin` or `right` from the doc (especially
since it doesn't really come for free in the code).

As a user I'd wonder if "align to right-fringe" means to align to
the beginning (i.e. left side) or end (i.e. right side) of the
right fringe.

[ And now I wonder: can Emacs have R2L modelines?  If so, what should
  happen in those?  ]

> +(defun mode-line-format-right-align ()
> +  "Right-align all following mode-line constructs.
> +
> +When the symbol `mode-line-format-right-align' appears in
> +`mode-line-format', return a string of one space, with a display
> +property to make it appear long enough to align anything after
> +that symbol to the right of the rendered mode line.  Exactly how
> +far to the right is controlled by `mode-line-right-align-edge'.
> +
> +It is important that the symbol `mode-line-format-right-align' be
> +included in `mode-line-format' (and not another similar construct
> +such as `(:eval (mode-line-format-right-align)').  This is because
> +the symbol `mode-line-format-right-align' is processed by
> +`format-mode-line' as a variable."

AFAICT, this function is internal to the implementation of the
`mode-line-format-right-align` mode-line spec.  So maybe it should use
"--" in its name.

> +  (let* ((rest (cdr (memq 'mode-line-format-right-align
> +			  mode-line-format)))

This is the ugly part of the implementation: the
`mode-line-format-right-align` has to "find itself".
I wonder if/how we could get rid of this wrinkle.

Maybe instead of a `mode-line-format` of the form:

    (..LEFT.. mode-line-format-right-align ..RIGHT..)

an alternative is to use

    (..LEFT.. (:eval (mode-line-format-right-align ..RIGHT..)))

I wonder if it would work as well (I'm worried that it means that
`..RIGHT..` is not processed directly by the C code by goes through the
`format-mode-line` ELisp function to turn it into an ELisp string
first and that could affect the result).

It would have the advantage that it doesn't process `..RIGHT..` twice,
and it should also be usable in `header-line-format` and friends.

It's not great tho :-(


        Stefan






  parent reply	other threads:[~2023-06-09 16:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 22:27 bug#62606: [PATCH] function to align mode-line elements to right hugo
2023-04-02  5:47 ` Eli Zaretskii
2023-05-06 14:14   ` hugo
2023-05-06 14:39     ` Eli Zaretskii
2023-06-05 20:45       ` hugo
2023-06-06 11:24         ` Eli Zaretskii
2023-06-09 12:47           ` hugo
2023-06-09 13:13             ` Eli Zaretskii
     [not found]               ` <f60acc21a937b413f6528264f233ebfe@heagren.com>
2023-06-09 14:52                 ` Eli Zaretskii
2023-04-02 16:19 ` Juri Linkov
2023-06-09 16:03 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-06-09 16:17   ` Eli Zaretskii
2023-06-09 16:52     ` bug#62606: R2L modelines (was: bug#62606: [PATCH] function to align mode-line elements to right) Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-19 19:06   ` bug#62606: [PATCH] function to align mode-line elements to right hugo
2023-06-24 12:05     ` Eli Zaretskii
2023-06-26 10:06       ` hugo
2023-06-26 11:55         ` Eli Zaretskii
2023-07-02 12:43           ` hugo
2023-07-06  7:35             ` Eli Zaretskii
     [not found] ` <handler.62606.D62606.168862894016990.notifdone@debbugs.gnu.org>
2023-07-14 16:37   ` Juri Linkov
2023-07-17 17:56     ` Juri Linkov
     [not found]       ` <CALDnm53v4O9cYcYwcqGpYVb4xVOw6t+FM1xX21k7HFxWyuiSaQ@mail.gmail.com>
     [not found]         ` <83fryrs1l8.fsf@gnu.org>
     [not found]           ` <87edebjcku.fsf@gmail.com>
     [not found]             ` <835xznro5i.fsf@gnu.org>
2024-01-21 10:20               ` João Távora
2024-01-21 10:27                 ` Eli Zaretskii
2024-01-21 10:39                   ` João Távora

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwv7csc7idp.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=62606@debbugs.gnu.org \
    --cc=hugo@heagren.com \
    --cc=monnier@iro.umontreal.ca \
    /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 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).