🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98594

Patch for bug in save-window-excursion

#98594
From: Jim Blandy
Date: Sat, 04 May 1991 06:34
65 lines
2705 bytes
Have I posted this before?  Duh?

current-window-configuration incorrectly saves the value of point in
the selected window.  Yukko.  Here is a way to see the bug in action:

start emacs -q.

Enter the following code:

	(global-set-key "\C-ce"
			'(lambda ()
			   (interactive)
			   (set-buffer "foo")
			   (save-window-excursion
			     (set-buffer "*scratch*"))))

Type `M-> LFD M-<' to evaluate the code and then go to the top of the
buffer.

Type `C-x 4 b foo RET' to make another buffer in another window.  Note
that the *scratch* window has saved point at the top of the buffer.

Type `C-x o M->' to switch to *scratch* (using the window's value for
point), and then go to the bottom of the window.

Type `C-c e' to run the code.  The save-window-excursion incorrectly
saves the window's value of point instead the buffer's value, and
restores it, making point jump to the beginning of the buffer.


Mon Apr 22 04:48:52 1991  Jim Blandy  (jimb at geech.gnu.ai.mit.edu)

	* window.c (save_window_save): Always get the selected window's
	value of point from its buffer, not just when it's also the
	current buffer.

*** window.c.~1~	Tue Jan  8 13:21:13 1991
--- window.c	Mon Apr 22 04:50:02 1991
*************** save_window_save (window, vector, i, max
*** 1835,1843 ****
        p->hscroll = w->hscroll;
        if (!NULL (w->buffer))
  	{
! 	  if (EQ (window, selected_window)
! 	      && XBUFFER (w->buffer) == current_buffer)
! 	    p->pointm = Fpoint_marker ();
  	  else
  	    p->pointm = Fcopy_marker (w->pointm);
  
--- 1835,1849 ----
        p->hscroll = w->hscroll;
        if (!NULL (w->buffer))
  	{
! 	  /* Save w's value of point in the window configuration.
! 	     If w is the selected window, then get the value of point
! 	     from the buffer; pointm is garbage in the selected window.  */
! 	  if (EQ (window, selected_window))
! 	    {
! 	      p->pointm = Fmake_marker ();
! 	      Fset_marker (p->pointm, BUF_PT (XBUFFER (w->buffer)),
! 			   w->buffer);
! 	    }
  	  else
  	    p->pointm = Fcopy_marker (w->pointm);
  
Technical Details
Message-ID: <9105040634.AA15831@pogo.gnu.ai.mit.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,d5d32f47574bba78,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-05-03 23:34:49 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!unreplyable!garbage
From: jimb@GNU.AI.MIT.EDU (Jim Blandy)
Newsgroups: gnu.emacs.bug
Subject: Patch for bug in save-window-excursion
Message-ID: <9105040634.AA15831@pogo.gnu.ai.mit.edu>
Date: 4 May 91 06:34:49 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 65
Approved: bug-gnu-emacs@prep.ai.mit.edu