From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>, emacs-devel@gnu.org
Cc: Martin Rudalics <rudalics@gmx.at>
Subject: Re: [Emacs-diffs] emacs-26 9bf66c6: Don't run FOR_EACH_FRAME when there's no frame left (Bug#29961)
Date: Fri, 15 Dec 2017 09:13:19 -0800 [thread overview]
Message-ID: <c18a20e9-c260-79eb-80bd-6a811a337bea@cs.ucla.edu> (raw)
In-Reply-To: <jwvwp1oezdc.fsf-monnier+emacsdiffs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 467 bytes --]
On 12/15/2017 08:23 AM, Stefan Monnier wrote:
> Is the problem caused by eassume (CONSP (Vframe_list))?
> If so, maybe we should simply remove it.
That's a good idea. However, some calls to FOR_EACH_FRAME do assume that
frame-list is non-nil, while others don't. So when we remove the eassume
from FOR_EACH_FRAME, we should add it to callers that have the
assumption (otherwise --enable-gcc-warnings would sometimes rightly
complain). I installed the attached.
[-- Attachment #2: 0001-FOR_EACH_FRAME-no-longer-assumes-frame-list.patch --]
[-- Type: text/x-patch, Size: 4037 bytes --]
From 3716d4c5f02abbcc5bad5f0c884302687bcbbb7e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 15 Dec 2017 09:07:52 -0800
Subject: [PATCH] FOR_EACH_FRAME no longer assumes frame-list
This cleans up a recent fix related to Bug#29661.
Suggested by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2017-12/msg00544.html
* src/frame.c (next_frame, prev_frame, delete_frame):
Restore debugging checks that Vframe_list is non-nil,
as FOR_EACH_FRAME no longer has these checks.
(delete_frame): Remove no-longer-needed checks that Vframe_list is
non-nil, as FOR_EACH_FRAME no longer assumes that.
* src/frame.h (FOR_EACH_FRAME): Do not assume Vframe_list is non-nil.
---
src/frame.c | 13 ++++++++-----
src/frame.h | 5 ++---
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/frame.c b/src/frame.c
index 66d1b5c759..63fa8abb7d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1607,6 +1607,8 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
Lisp_Object f, tail;
int passed = 0;
+ eassume (CONSP (Vframe_list));
+
while (passed < 2)
FOR_EACH_FRAME (tail, f)
{
@@ -1629,6 +1631,8 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf)
{
Lisp_Object f, tail, prev = Qnil;
+ eassume (CONSP (Vframe_list));
+
FOR_EACH_FRAME (tail, f)
{
if (EQ (frame, f) && !NILP (prev))
@@ -1914,6 +1918,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
if (f == sf)
{
Lisp_Object tail;
+ eassume (CONSP (Vframe_list));
/* Look for another visible frame on the same terminal.
Do not call next_frame here because it may loop forever.
@@ -2058,7 +2063,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
/* If we've deleted the last_nonminibuf_frame, then try to find
another one. */
- if (f == last_nonminibuf_frame && !NILP (Vframe_list))
+ if (f == last_nonminibuf_frame)
{
last_nonminibuf_frame = 0;
@@ -2076,7 +2081,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
/* If there's no other frame on the same kboard, get out of
single-kboard state if we're in it for this kboard. */
- if (kb != NULL && !NILP (Vframe_list))
+ if (kb != NULL)
{
/* Some frame we found on the same kboard, or nil if there are none. */
Lisp_Object frame_on_same_kboard = Qnil;
@@ -2093,9 +2098,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
/* If we've deleted this keyboard's default_minibuffer_frame, try to
find another one. Prefer minibuffer-only frames, but also notice
frames with other windows. */
- if (kb != NULL
- && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame))
- && !NILP (Vframe_list))
+ if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame)))
{
/* The last frame we saw with a minibuffer, minibuffer-only or not. */
Lisp_Object frame_with_minibuf = Qnil;
diff --git a/src/frame.h b/src/frame.h
index a3b7763643..a5d4e4fc88 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1149,8 +1149,7 @@ default_pixels_per_inch_y (void)
/* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
`for' loop which iterates over the elements of Vframe_list. The
loop will set FRAME_VAR, a Lisp_Object, to each frame in
- Vframe_list in succession and execute the statement. Vframe_list
- should be nonempty, so the body is executed at least once. LIST_VAR
+ Vframe_list in succession and execute the statement. LIST_VAR
should be a Lisp_Object too; it is used to iterate through the
Vframe_list. Note that this macro walks over child frames and
the tooltip frame as well.
@@ -1160,7 +1159,7 @@ default_pixels_per_inch_y (void)
something which executes the statement once. */
#define FOR_EACH_FRAME(list_var, frame_var) \
- for ((list_var) = (eassume (CONSP (Vframe_list)), Vframe_list); \
+ for ((list_var) = Vframe_list; \
(CONSP (list_var) \
&& (frame_var = XCAR (list_var), true)); \
list_var = XCDR (list_var))
--
2.14.3
next prev parent reply other threads:[~2017-12-15 17:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20171215073120.7671.79446@vcs0.savannah.gnu.org>
[not found] ` <20171215073122.52703204D3@vcs0.savannah.gnu.org>
2017-12-15 16:23 ` [Emacs-diffs] emacs-26 9bf66c6: Don't run FOR_EACH_FRAME when there's no frame left (Bug#29961) Stefan Monnier
2017-12-15 17:13 ` Paul Eggert [this message]
2017-12-15 18:17 ` martin rudalics
2017-12-15 19:09 ` Paul Eggert
2017-12-16 9:42 ` martin rudalics
2017-12-17 0:50 ` Paul Eggert
2017-12-17 10:46 ` martin rudalics
2017-12-18 0:39 ` Paul Eggert
2017-12-18 7:26 ` martin rudalics
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=c18a20e9-c260-79eb-80bd-6a811a337bea@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
--cc=rudalics@gmx.at \
/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.