[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Test whether buffer/window is ready for start_display, etc.
From: |
Keith David Bershatsky |
Subject: |
Test whether buffer/window is ready for start_display, etc. |
Date: |
Wed, 27 Sep 2017 19:21:17 -0700 |
In developing implementation of my own feature requests to draw crosshairs
(#17684) using multiple fake cursors (#22873), I have come across situations
when Emacs is starting up and restoring buffers (custom version of desktop.el)
such that several internal functions cause Emacs to crash -- presumably because
the combination of buffer and window are not ready yet. I am presently using
the following five (5) tests to see whether window/buffer are ready for things
like `start_display`, `move_it_to`, etc. Is there a better test to see whether
the buffer/window combination is ready for me to get to work?
if (w != XWINDOW (selected_window))
return;
if (!WINDOW_VALID_P (selected_window))
return;
Lisp_Object buf = w->contents;
CHECK_BUFFER (buf);
struct buffer *b = XBUFFER (buf);
/* eassert (CHARPOS (pos) >= BEGV && CHARPOS (pos) <= ZV);
eassert (charpos == BYTE_TO_CHAR (bytepos));
eassert (BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE (b));
*/
ptrdiff_t charpos = marker_position (w->start);
ptrdiff_t bytepos = marker_byte_position (w->start);
bool barf_crash_one = (charpos >= BEGV && charpos <= ZV) ? false : true;
if (barf_crash_one)
return;
bool barf_crash_two = (charpos == BYTE_TO_CHAR (bytepos)) ? false : true;
if (barf_crash_two)
return;
bool barf_crash_three = (BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE
(b)) ? false : true;
if (barf_crash_three)
return;
Thanks,
Keith
- Test whether buffer/window is ready for start_display, etc.,
Keith David Bershatsky <=