[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#28771: 26.0.60; A couple space display property feature requests
From: |
Alex |
Subject: |
bug#28771: 26.0.60; A couple space display property feature requests |
Date: |
Mon, 09 Oct 2017 20:02:23 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) |
Alex <agrambot@gmail.com> writes:
> 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.
Here's a diff that implements both #1 and #2:
diff --git a/src/xdisp.c b/src/xdisp.c
index b14b7daf2b..d5fa3a1cfe 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25210,6 +25210,10 @@ calc_pixel_width_or_height (double *res, struct it
*it, Lisp_Object prop,
+ (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)
? WINDOW_RIGHT_FRINGE_WIDTH (it->w)
: 0)));
+ if (EQ (prop, Qleft_edge))
+ return OK_ALIGN_TO (WINDOW_LEFT_PIXEL_EDGE (it->w));
+ if (EQ (prop, Qright_edge))
+ return OK_ALIGN_TO (WINDOW_RIGHT_PIXEL_EDGE (it->w));
}
else
{
@@ -25223,6 +25227,13 @@ calc_pixel_width_or_height (double *res, struct it
*it, Lisp_Object prop,
return OK_PIXELS (WINDOW_RIGHT_MARGIN_WIDTH (it->w));
if (EQ (prop, Qscroll_bar))
return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w));
+ if (EQ (prop, Qleft))
+ return OK_PIXELS (window_box_left_offset (it->w, TEXT_AREA));
+ if (EQ (prop, Qright))
+ return OK_PIXELS (window_box_right_offset (it->w, TEXT_AREA));
+ if (EQ (prop, Qcenter))
+ return OK_PIXELS (window_box_left_offset (it->w, TEXT_AREA)
+ + window_box_width (it->w, TEXT_AREA) / 2);
}
prop = buffer_local_value (prop, it->w->contents);
@@ -32207,6 +32218,8 @@ They are still logged to the *Messages* buffer. */);
DEFSYM (Qspace, "space");
DEFSYM (Qmargin, "margin");
DEFSYM (Qpointer, "pointer");
+ DEFSYM (Qleft_edge, "left-edge");
+ DEFSYM (Qright_edge, "right-edge");
DEFSYM (Qleft_margin, "left-margin");
DEFSYM (Qright_margin, "right-margin");
DEFSYM (Qcenter, "center");