[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#62606: [PATCH] function to align mode-line elements to right
From: |
Stefan Monnier |
Subject: |
bug#62606: [PATCH] function to align mode-line elements to right |
Date: |
Fri, 09 Jun 2023 12:03:02 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> 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
- bug#62606: [PATCH] function to align mode-line elements to right,
Stefan Monnier <=