From: Keith David Bershatsky <esq@lawlist.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: Test whether buffer/window is ready for start_display, etc.
Date: Wed, 27 Sep 2017 19:21:17 -0700 [thread overview]
Message-ID: <m2h8vnpnqa.wl%esq@lawlist.com> (raw)
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
next reply other threads:[~2017-09-28 2:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 2:21 Keith David Bershatsky [this message]
2017-09-29 16:08 ` Test whether buffer/window is ready for start_display, etc Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2017-10-05 2:35 Keith David Bershatsky
2017-10-05 8:03 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2h8vnpnqa.wl%esq@lawlist.com \
--to=esq@lawlist.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.