Subject: Re: bug#20734: 25.0.50; "Args out of range" with help-window-select t
From: Nicolas Richard <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked]
Date: Sat, 06 Jun 2015 10:44:26 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

>> Ok. I think I understand now.  What about adding an assertion to make
>> sure current_buffer is shown in selected_window at that point?
>
> That'd be fine with me.

I can suggest :
From 52cd3204743442fc6d8fc281ed3d9b0b0e6a88e4 Mon Sep 17 00:00:00 2001
From: Nicolas Richard <[email-masked]>
Date: Sat, 6 Jun 2015 10:05:07 +0200
Subject: [PATCH] Add assertion in adjust_point_for_property

* src/keyboard.c (adjust_point_for_property): Add eassert for
current buffer being shown in selected window.
---
 src/keyboard.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/keyboard.c b/src/keyboard.c
index bedd10b..23f7ce7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1687,6 +1687,8 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
   bool check_composition = ! modified, check_display = 1, check_invisible = 1;
   ptrdiff_t orig_pt = PT;
 
+  eassert (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer);
+
   /* FIXME: cycling is probably not necessary because these properties
      can't be usefully combined anyway.  */
   while (check_composition || check_display || check_invisible)
-- 
1.9.1

>>   && EQ (XBUFFER (XWINDOW (selected_window)->contents), current_buffer)

>                     in that case, you don't need EQ, just use == to
> compare 2 C pointers.

Ok, I pushed that solution as d31cd49 and I mark the bug as done. Thanks
for your guidance.

-- 
Nico.