From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Test whether buffer/window is ready for start_display, etc. Date: Wed, 27 Sep 2017 19:21:17 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1506565307 5320 195.159.176.226 (28 Sep 2017 02:21:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 28 Sep 2017 02:21:47 +0000 (UTC) To: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 28 04:21:43 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxOSK-0000mf-NI for ged-emacs-devel@m.gmane.org; Thu, 28 Sep 2017 04:21:41 +0200 Original-Received: from localhost ([::1]:57029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxOSR-0000WG-Nt for ged-emacs-devel@m.gmane.org; Wed, 27 Sep 2017 22:21:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxOSI-0000W7-8G for emacs-devel@gnu.org; Wed, 27 Sep 2017 22:21:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxOSF-0002oJ-40 for emacs-devel@gnu.org; Wed, 27 Sep 2017 22:21:38 -0400 Original-Received: from gateway20.websitewelcome.com ([192.185.47.18]:13410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxOSE-0002h5-S5 for emacs-devel@gnu.org; Wed, 27 Sep 2017 22:21:35 -0400 Original-Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 27D90400E6892 for ; Wed, 27 Sep 2017 21:21:20 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id xOStdkrzg5b6TxOStdQtqW; Wed, 27 Sep 2017 21:22:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/Y4CFe4Z2s79mc5xpfE2B3vdCw8AjiqAIypwR0WML6g=; b=cUzirwKa5fCV+9S18NJ1rebpEP v7RXn9/SJvjOkSCx7Ivl46MuZL65ELO1yDJuuFEnEgiGSNkv7K8LDX5MANeRHN+BZlyy96aFasc27 +hqbfJOIr/qabL5s8baVwDTSEcS5M+Q+2Zd1UEm4CVSrN8ubmrH4VwT2Z5JEBBYZGjjxBWMZunpqf tHX7tKOinrjipwwHKyMZWNCd40QYMw+XQwvomz3cszTBJ4d1rdJ2//uLo1PUZGrX8j6wtfdpvtu4i PjAJivZkDqP1Oih0vf1rAV+q2ACr1EI/W4j03KBDWYIug2LQv2MAP1lNI0bCmWaeldoVacMfe9hYX Ud4epQiA==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:54975 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1dxORz-000g8F-G5 for emacs-devel@gnu.org; Wed, 27 Sep 2017 21:21:19 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1dxORz-000g8F-G5 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private) [45.48.239.195]:54975 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.47.18 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218840 Archived-At: 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