Package: emacs;
Reported by: Alex <agrambot <at> gmail.com>
Date: Tue, 10 Oct 2017 00:22:01 UTC
Severity: wishlist
Found in version 26.0.60
View this message in rfc822 format
From: Alex <agrambot <at> gmail.com> To: Eli Zaretskii <eliz <at> gnu.org> Cc: 28771 <at> debbugs.gnu.org Subject: bug#28771: 26.0.60; A couple space display property feature requests Date: Tue, 10 Oct 2017 11:54:41 -0600
Eli Zaretskii <eliz <at> gnu.org> writes: >> From: Alex <agrambot <at> gmail.com> >> Date: Mon, 09 Oct 2017 18:20:42 -0600 >> >> 1. Specifying the pixel width to the left/center/right of the text area. >> This is helpful (I believe it's necessary if I want it to be robust) >> when one wants to pad either side of a string with the same number of >> pixels and the left side uses (:align-to 0). >> >> I could use (:width (+ left-fringe left-margin)) for the right >> padding, but this doesn't take into account line-number display, as >> well as the scroll-bar width (if it's on the left). >> >> 2. Specifying the pixel position relative to the left or right edge of >> the window. The right edge of the window currently may be the right >> edge of the right fringe or the scroll bar, depending on what side it >> is on. Also, just in the case that in the future the >> fringe/scroll-bar may not be the outermost elements, there should be >> a way to explicitly specify one of the edges. > > These two requests are no in the original message, and I admit I don't > really understand the situations they describe. Can you elaborate > about them, preferably with an example that shows what is currently > possible and an explanation why the current capabilities are > insufficient? (Yes, I've seen the patches you propose, but I still > would like to understand the problems better.) Right, they're additions that I felt should go directly to a bug report. 1. There is currently no robust way to specify a pixel width to the center or left/right edge of the text area in the 'space' display spec. This is because there's no way to tell what's before the left edge of the text area. If there's a left-side scroll-bar, then its width should be included; but if it's on the right, its width shouldn't be. :align-to currently allows for this calculation, but :width doesn't. The diff adds the same calculation to :width. As for an example, try this in a graphical emacs -Q: (setq header-line-format (propertize (concat (propertize " " 'display '(space :align-to 0)) "Test" (propertize " " 'display '(space :width (+ left-fringe left-margin)))) 'face 'highlight)) By default, the spaces before and after test are equally sized. Even if you disable fringe-mode or enable margins (e.g. linum-mode), the spaces are equal. However, try setting the scroll-bar to appear on the left. Now, the left space is noticeably bigger than the right. Changing the last space's :width spec to be '(+ left-fringe left-margin scroll-bar)' will now make the spaces equal with a left scroll-bar, but unequal with a right scroll-bar. If you apply my diff and change the second space's :width spec to be 'left', then it is correct in both cases. I don't know of a good use-case for :width center or :width right, but I figured that for completeness I might as well implement them. 2. Suppose you want to align a string to the right edge of the window. I couldn't find a way to do this currently since there's no guarantee what elements are on the left/right edges. Try: (setq header-line-format (concat (propertize " " 'display '(space :align-to (- (+ scroll-bar scroll-bar) 4))) "Test")) This works if there's a right scroll-bar (or if there's none, oddly enough), but not if there's a left scroll-bar. Replacing `scroll-bar' with `right-fringe' doesn't work if there's a right scroll-bar. Replacing the :align-to spec with `right-edge' works in all cases. A similar argument can be made for aligning from the left edge. >> 3. Following from "1." and the help-gnu-emacs thread, it would be nice >> if there was a display property that allowed you to pad a string on >> both sides with a pixel-specified space instead of surrounding it >> with 2 pixel-specified spaces. > > I replied on help-gnu-emacs. In a nutshell, the 'space' display spec > is a replacing spec, so it cannot be easily used on non-space text. > You could probably have a before-string whose value is a space with > the 'space' display spec, if that makes any difference. Can you put overlays in the header-line? That's my use-case at the moment. > use the space-width spec, as described on help-gnu-emacs. I believe in my case (since the text may contain spaces), that's equivalent to just the :width spec on the first/last spaces. #3 is just a convenience request -- it makes dealing with pixel-spaces a bit easier, but as long as #1 is implemented then I don't think it bring any new functionality. Is there currently no display spec that allows for appending/prepending (or would it be hard to add)? If so, then #3 can be ignored.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.