Subject: Re: bug#15457: 24.3.50; buffer local `window-point-insertion-type'
From: Stefan Monnier <[email-masked]>
To: Michael Heerdegen <[email-masked]>
Cc: [email-masked]
Date: Wed, 16 Apr 2014 10:00:44 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> while experimenting with my logging mode, I stumbled over an
> inconsistency regarding `window-point-insertion-type'.  Recipe from
> emacs -Q:

> (1)  Eval the attached defun

> (2a) Eval (window-point-insertion-type-test t)

> Result: After hitting RET (or C-g), window-point of the second window is
> restored to the value it had before the recursive edit (i.e. 1 in this
> case).

> Now, repeat the recipe, but with

> (2b) Eval (window-point-insertion-type-test nil)

> Result: window-point in the second window remains at the end of the
> buffer.

That seems to be because the insertion type of the markers saved by
window-configuration is determined by the value of
window-point-insertion-type in the current-buffer rather than each
window's buffer.

I installed the patch below into emacs-24, which should fix it,

        Stefan

=== modified file 'src/window.c'
--- src/window.c	2014-03-07 15:11:12 +0000
+++ src/window.c	2014-04-16 13:58:18 +0000
@@ -55,6 +55,7 @@
 static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
 static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of;
 static Lisp_Object Qfloor, Qceiling;
+static Lisp_Object Qwindow_point_insertion_type;
 
 static int displayed_window_lines (struct window *);
 static int count_windows (struct window *);
@@ -124,7 +125,7 @@
 /* Hook to run when window config changes.  */
 static Lisp_Object Qwindow_configuration_change_hook;
 
-/* Used by the function window_scroll_pixel_based */
+/* Used by the function window_scroll_pixel_based.  */
 static int window_scroll_pixel_based_preserve_x;
 static int window_scroll_pixel_based_preserve_y;
 
@@ -6618,7 +6619,8 @@
 	  else
 	    p->pointm = Fcopy_marker (w->pointm, Qnil);
 	  XMARKER (p->pointm)->insertion_type
-	    = !NILP (Vwindow_point_insertion_type);
+	    = !NILP (buffer_local_value_1 /* Don't signal error if void.  */
+		     (Qwindow_point_insertion_type, w->contents));
 
 	  p->start = Fcopy_marker (w->start, Qnil);
 	  p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
@@ -7235,6 +7237,7 @@
   DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type,
 	       doc: /* Type of marker to use for `window-point'.  */);
   Vwindow_point_insertion_type = Qnil;
+  DEFSYM (Qwindow_point_insertion_type, "window_point_insertion_type");
 
   DEFVAR_LISP ("window-configuration-change-hook",
 	       Vwindow_configuration_change_hook,