summaryrefslogtreecommitdiff
path: root/src/fringe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fringe.c')
-rw-r--r--src/fringe.c75
1 files changed, 38 insertions, 37 deletions
diff --git a/src/fringe.c b/src/fringe.c
index 4151386ceb8..a7e8dad482e 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "frame.h"
+#include "ptr-bounds.h"
#include "window.h"
#include "dispextern.h"
#include "buffer.h"
@@ -487,10 +488,10 @@ lookup_fringe_bitmap (Lisp_Object bitmap)
EMACS_INT bn;
bitmap = Fget (bitmap, Qfringe);
- if (!INTEGERP (bitmap))
+ if (!FIXNUMP (bitmap))
return 0;
- bn = XINT (bitmap);
+ bn = XFIXNUM (bitmap);
if (bn > NO_FRINGE_BITMAP
&& bn < max_used_fringe_bitmap
&& (bn < MAX_STANDARD_FRINGE_BITMAPS
@@ -518,7 +519,7 @@ get_fringe_bitmap_name (int bn)
return Qnil;
bitmaps = Vfringe_bitmaps;
- num = make_number (bn);
+ num = make_fixnum (bn);
while (CONSP (bitmaps))
{
@@ -586,8 +587,8 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
if (face_id == DEFAULT_FACE_ID)
{
Lisp_Object face = fringe_faces[which];
- face_id = NILP (face) ? lookup_named_face (f, Qfringe, false)
- : lookup_derived_face (f, face, FRINGE_FACE_ID, 0);
+ face_id = NILP (face) ? lookup_named_face (w, f, Qfringe, false)
+ : lookup_derived_face (w, f, face, FRINGE_FACE_ID, 0);
if (face_id < 0)
face_id = FRINGE_FACE_ID;
}
@@ -742,12 +743,12 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
return NO_FRINGE_BITMAP;
if (CONSP (bm1))
{
- ln1 = XINT (Flength (bm1));
+ ln1 = XFIXNUM (Flength (bm1));
if (partial_p)
{
if (ln1 > ix2)
{
- bm = Fnth (make_number (ix2), bm1);
+ bm = Fnth (make_fixnum (ix2), bm1);
if (!EQ (bm, Qt))
goto found;
}
@@ -756,7 +757,7 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
{
if (ln1 > ix1)
{
- bm = Fnth (make_number (ix1), bm1);
+ bm = Fnth (make_fixnum (ix1), bm1);
if (!EQ (bm, Qt))
goto found;
}
@@ -777,12 +778,12 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
{
if (CONSP (bm2))
{
- ln2 = XINT (Flength (bm2));
+ ln2 = XFIXNUM (Flength (bm2));
if (partial_p)
{
if (ln2 > ix2)
{
- bm = Fnth (make_number (ix2), bm2);
+ bm = Fnth (make_fixnum (ix2), bm2);
if (!EQ (bm, Qt))
goto found;
}
@@ -794,14 +795,14 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
if (ln1 > ix1)
{
- bm = Fnth (make_number (ix1), bm1);
+ bm = Fnth (make_fixnum (ix1), bm1);
if (!EQ (bm, Qt))
goto found;
}
if (ln2 > ix1)
{
- bm = Fnth (make_number (ix1), bm2);
+ bm = Fnth (make_fixnum (ix1), bm2);
if (!EQ (bm, Qt))
goto found;
return NO_FRINGE_BITMAP;
@@ -908,6 +909,12 @@ draw_window_fringes (struct window *w, bool no_fringe_p)
if (w->pseudo_window_p)
return updated_p;
+ /* We must switch to the window's buffer to use its local value of
+ the fringe face, in case it's been remapped in face-remapping-alist. */
+ Lisp_Object window_buffer = w->contents;
+ struct buffer *oldbuf = current_buffer;
+ set_buffer_internal_1 (XBUFFER (window_buffer));
+
/* Must draw line if no fringe */
if (no_fringe_p
&& (WINDOW_LEFT_FRINGE_WIDTH (w) == 0
@@ -925,6 +932,8 @@ draw_window_fringes (struct window *w, bool no_fringe_p)
updated_p = 1;
}
+ set_buffer_internal_1 (oldbuf);
+
return updated_p;
}
@@ -1508,8 +1517,8 @@ If BITMAP already exists, the existing definition is replaced. */)
fb.height = h;
else
{
- CHECK_NUMBER (height);
- fb.height = max (0, min (XINT (height), 255));
+ CHECK_FIXNUM (height);
+ fb.height = max (0, min (XFIXNUM (height), 255));
if (fb.height > h)
{
fill1 = (fb.height - h) / 2;
@@ -1521,8 +1530,8 @@ If BITMAP already exists, the existing definition is replaced. */)
fb.width = 8;
else
{
- CHECK_NUMBER (width);
- fb.width = max (0, min (XINT (width), 255));
+ CHECK_FIXNUM (width);
+ fb.width = max (0, min (XFIXNUM (width), 255));
}
fb.period = 0;
@@ -1585,13 +1594,15 @@ If BITMAP already exists, the existing definition is replaced. */)
}
Vfringe_bitmaps = Fcons (bitmap, Vfringe_bitmaps);
- Fput (bitmap, Qfringe, make_number (n));
+ Fput (bitmap, Qfringe, make_fixnum (n));
}
fb.dynamic = true;
xfb = xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW);
- fb.bits = b = (unsigned short *) (xfb + 1);
+ fb.bits = b = ((unsigned short *)
+ ptr_bounds_clip (xfb + 1, fb.height * BYTES_PER_BITMAP_ROW));
+ xfb = ptr_bounds_clip (xfb, sizeof *xfb);
memset (b, 0, fb.height);
j = 0;
@@ -1601,8 +1612,8 @@ If BITMAP already exists, the existing definition is replaced. */)
b[j++] = 0;
for (i = 0; i < h && j < fb.height; i++)
{
- Lisp_Object elt = Faref (bits, make_number (i));
- b[j++] = NUMBERP (elt) ? XINT (elt) : 0;
+ Lisp_Object elt = Faref (bits, make_fixnum (i));
+ b[j++] = FIXNUMP (elt) ? XFIXNUM (elt) : 0;
}
for (i = 0; i < fill2 && j < fb.height; i++)
b[j++] = 0;
@@ -1630,20 +1641,10 @@ If FACE is nil, reset face to default fringe face. */)
if (!n)
error ("Undefined fringe bitmap");
- /* The purpose of the following code is to signal an error if FACE
- is not a face. This is for the caller's convenience only; the
- redisplay code should be able to fail gracefully. Skip the check
- if FRINGE_FACE_ID is unrealized (as in batch mode and during
- daemon startup). */
- if (!NILP (face))
- {
- struct frame *f = SELECTED_FRAME ();
-
- if (FACE_FROM_ID_OR_NULL (f, FRINGE_FACE_ID)
- && lookup_derived_face (f, face, FRINGE_FACE_ID, 1) < 0)
- error ("No such face");
- }
-
+ /* We used to check, as a convenience to callers, for basic face
+ validity here, but since validity can depend on the specific
+ _window_ in which this buffer is being displayed, defer the check
+ to redisplay, which can cope with bad face specifications. */
fringe_faces[n] = face;
return Qnil;
}
@@ -1668,10 +1669,10 @@ Return nil if POS is not visible in WINDOW. */)
if (!NILP (pos))
{
- CHECK_NUMBER_COERCE_MARKER (pos);
- if (! (BEGV <= XINT (pos) && XINT (pos) <= ZV))
+ CHECK_FIXNUM_COERCE_MARKER (pos);
+ if (! (BEGV <= XFIXNUM (pos) && XFIXNUM (pos) <= ZV))
args_out_of_range (window, pos);
- textpos = XINT (pos);
+ textpos = XFIXNUM (pos);
}
else if (w == XWINDOW (selected_window))
textpos = PT;