GNU bug report logs - #33492
buffer-local-variables does not include buffer-undo-list

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Terje Larsen <terlar@HIDDEN>; Keywords: confirmed; dated Sat, 24 Nov 2018 20:55:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 33492 <at> debbugs.gnu.org:


Received: (at 33492) by debbugs.gnu.org; 30 Jan 2019 00:31:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 29 19:31:09 2019
Received: from localhost ([127.0.0.1]:50956 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1godmX-0005XF-Cp
	for submit <at> debbugs.gnu.org; Tue, 29 Jan 2019 19:31:09 -0500
Received: from eggs.gnu.org ([209.51.188.92]:40913)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rgm@HIDDEN>) id 1godmV-0005Wt-KE
 for 33492 <at> debbugs.gnu.org; Tue, 29 Jan 2019 19:31:07 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:35582)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rgm@HIDDEN>)
 id 1godmM-0006vD-G1; Tue, 29 Jan 2019 19:31:00 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.82)
 (envelope-from <rgm@HIDDEN>)
 id 1godmM-00063v-Bs; Tue, 29 Jan 2019 19:30:58 -0500
From: Glenn Morris <rgm@HIDDEN>
To: 33492 <at> debbugs.gnu.org
Subject: Re: bug#33492: 27.0.50;
 desktop-locals-to-save won't consider buffer-undo-list as local
References: <CAGoWm-Zd4x7MNh_+uKWKJ_tb7PjYVTdNVYF-uPQu1hmdP+_PQw@HIDDEN>
 <g74lc23shw.fsf@HIDDEN> <bb7egwvpo1.fsf@HIDDEN>
X-Spook: Malware Hugo Chavez Plane Dock North Korea Water borne
X-Ran: sP^lo=5s*pHl^u_SS6?yrMUYWoD%j*Y}oIUaA@V=TV,x]#74}aN39+ZPdTxH%|3QZ_y#?A
X-Hue: red
X-Attribution: GM
Date: Tue, 29 Jan 2019 19:30:58 -0500
In-Reply-To: <bb7egwvpo1.fsf@HIDDEN> (Glenn Morris's message of
 "Wed, 28 Nov 2018 16:49:02 -0500")
Message-ID: <rg8sz3yojh.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 33492
Cc: Terje Larsen <terlar@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Glenn Morris wrote:

>> This issue (buffer-local-variables does not include buffer-undo-list)
>> is present since Emacs 24.3, due to 36429c8, which moved undo_list to
>> the end of struct buffer.
>
> The following works, but I don't know if it is the best solution.
>
> --- i/src/buffer.c
> +++ w/src/buffer.c
> @@ -1266,6 +1266,20 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone)
>    return result;
>  }
>  
> +Lisp_Object
> +buffer_local_variables_1 (struct buffer *buf, int offset)
> +{
> +  int idx = PER_BUFFER_IDX (offset);
> +  if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
> +      && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
> +    {
> +      Lisp_Object sym = PER_BUFFER_SYMBOL (offset);
> +      Lisp_Object val = per_buffer_value (buf, offset);
> +      return EQ (val, Qunbound) ? sym : Fcons (sym, val);
> +    }
> +  return Qnil;
> +}
> +
>  DEFUN ("buffer-local-variables", Fbuffer_local_variables,
>         Sbuffer_local_variables, 0, 1, 0,
>         doc: /* Return an alist of variables that are buffer-local in BUFFER.
> @@ -1277,6 +1291,7 @@ No argument or nil as argument means use current buffer as BUFFER.  */)
>  {
>    struct buffer *buf = decode_buffer (buffer);
>    Lisp_Object result = buffer_lisp_local_variables (buf, 0);
> +  Lisp_Object tem;
>  
>    /* Add on all the variables stored in special slots.  */
>    {
> @@ -1284,18 +1299,16 @@ No argument or nil as argument means use current buffer as BUFFER.  */)
>  
>      FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
>        {
> -	idx = PER_BUFFER_IDX (offset);
> -	if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
> -	    && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
> -	  {
> -	    Lisp_Object sym = PER_BUFFER_SYMBOL (offset);
> -	    Lisp_Object val = per_buffer_value (buf, offset);
> -	    result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val),
> -			    result);
> -	  }
> +        tem = buffer_local_variables_1 (buf, offset);
> +        if (!NILP (tem))
> +          result = Fcons (tem, result);
>        }
>    }
>  
> +  tem = buffer_local_variables_1 (buf, PER_BUFFER_VAR_OFFSET (undo_list));
> +  if (!NILP (tem))
> +    result = Fcons (tem, result);
> +
>    return result;
>  }


I was going to apply this, there having been no comments, but then I
noticed that since the advent of portable dumper (or since 978cf88 at
least), it's not completely right. It adds an entry for buffer-undo-list
to buffer-local-variables, but with key = "nil" rather than
"buffer-undo-list". Which implies that
PER_BUFFER_SYMBOL (PER_BUFFER_VAR_OFFSET (undo_list))
now returns nil instead of 'buffer-undo-list.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33492; Package emacs. Full text available.

Message received at 33492 <at> debbugs.gnu.org:


Received: (at 33492) by debbugs.gnu.org; 28 Nov 2018 21:49:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 28 16:49:19 2018
Received: from localhost ([127.0.0.1]:53865 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gS7hv-000189-LF
	for submit <at> debbugs.gnu.org; Wed, 28 Nov 2018 16:49:19 -0500
Received: from eggs.gnu.org ([208.118.235.92]:60590)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rgm@HIDDEN>) id 1gS7ht-00017x-Ox
 for 33492 <at> debbugs.gnu.org; Wed, 28 Nov 2018 16:49:17 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rgm@HIDDEN>) id 1gS7hm-0001cB-N0
 for 33492 <at> debbugs.gnu.org; Wed, 28 Nov 2018 16:49:12 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54049)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rgm@HIDDEN>)
 id 1gS7hg-0001Zd-En; Wed, 28 Nov 2018 16:49:05 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.82)
 (envelope-from <rgm@HIDDEN>)
 id 1gS7he-0000rY-41; Wed, 28 Nov 2018 16:49:02 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Terje Larsen <terlar@HIDDEN>
Subject: Re: bug#33492: 27.0.50;
 desktop-locals-to-save won't consider buffer-undo-list as local
References: <CAGoWm-Zd4x7MNh_+uKWKJ_tb7PjYVTdNVYF-uPQu1hmdP+_PQw@HIDDEN>
 <g74lc23shw.fsf@HIDDEN>
X-Spook: CDC AMW Magnitude Federal Emergency Management Agency
X-Ran: _I?]#-S*fDm,{3xxH4/ZRtxBWp!p=usHnFj\NMjR.O.so'kC:mD+x<KUU_O:1o;K>L<rbd
X-Hue: magenta
X-Attribution: GM
Date: Wed, 28 Nov 2018 16:49:02 -0500
In-Reply-To: <g74lc23shw.fsf@HIDDEN> (Glenn Morris's message of
 "Tue, 27 Nov 2018 20:23:07 -0500")
Message-ID: <bb7egwvpo1.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33492
Cc: 33492 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

Glenn Morris wrote:

> This issue (buffer-local-variables does not include buffer-undo-list)
> is present since Emacs 24.3, due to 36429c8, which moved undo_list to
> the end of struct buffer.

The following works, but I don't know if it is the best solution.

--- i/src/buffer.c
+++ w/src/buffer.c
@@ -1266,6 +1266,20 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone)
   return result;
 }
 
+Lisp_Object
+buffer_local_variables_1 (struct buffer *buf, int offset)
+{
+  int idx = PER_BUFFER_IDX (offset);
+  if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+      && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
+    {
+      Lisp_Object sym = PER_BUFFER_SYMBOL (offset);
+      Lisp_Object val = per_buffer_value (buf, offset);
+      return EQ (val, Qunbound) ? sym : Fcons (sym, val);
+    }
+  return Qnil;
+}
+
 DEFUN ("buffer-local-variables", Fbuffer_local_variables,
        Sbuffer_local_variables, 0, 1, 0,
        doc: /* Return an alist of variables that are buffer-local in BUFFER.
@@ -1277,6 +1291,7 @@ No argument or nil as argument means use current buffer as BUFFER.  */)
 {
   struct buffer *buf = decode_buffer (buffer);
   Lisp_Object result = buffer_lisp_local_variables (buf, 0);
+  Lisp_Object tem;
 
   /* Add on all the variables stored in special slots.  */
   {
@@ -1284,18 +1299,16 @@ No argument or nil as argument means use current buffer as BUFFER.  */)
 
     FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
       {
-	idx = PER_BUFFER_IDX (offset);
-	if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
-	    && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
-	  {
-	    Lisp_Object sym = PER_BUFFER_SYMBOL (offset);
-	    Lisp_Object val = per_buffer_value (buf, offset);
-	    result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val),
-			    result);
-	  }
+        tem = buffer_local_variables_1 (buf, offset);
+        if (!NILP (tem))
+          result = Fcons (tem, result);
       }
   }
 
+  tem = buffer_local_variables_1 (buf, PER_BUFFER_VAR_OFFSET (undo_list));
+  if (!NILP (tem))
+    result = Fcons (tem, result);
+
   return result;
 }




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33492; Package emacs. Full text available.
Added tag(s) confirmed. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Changed bug title to 'buffer-local-variables does not include buffer-undo-list' from '27.0.50; desktop-locals-to-save won't consider buffer-undo-list as local' Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug Marked as found in versions 24.3. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 33492 <at> debbugs.gnu.org:


Received: (at 33492) by debbugs.gnu.org; 28 Nov 2018 01:23:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 27 20:23:15 2018
Received: from localhost ([127.0.0.1]:52675 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gRoZP-0005fa-N8
	for submit <at> debbugs.gnu.org; Tue, 27 Nov 2018 20:23:15 -0500
Received: from eggs.gnu.org ([208.118.235.92]:52048)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rgm@HIDDEN>) id 1gRoZO-0005fP-IQ
 for 33492 <at> debbugs.gnu.org; Tue, 27 Nov 2018 20:23:14 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rgm@HIDDEN>) id 1gRoZI-0005Cf-M7
 for 33492 <at> debbugs.gnu.org; Tue, 27 Nov 2018 20:23:09 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, UNRESOLVED_TEMPLATE
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43207)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rgm@HIDDEN>)
 id 1gRoZH-0005Bf-Fo; Tue, 27 Nov 2018 20:23:07 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.82)
 (envelope-from <rgm@HIDDEN>)
 id 1gRoZH-0003Od-Ap; Tue, 27 Nov 2018 20:23:07 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Terje Larsen <terlar@HIDDEN>
Subject: Re: bug#33492: 27.0.50;
 desktop-locals-to-save won't consider buffer-undo-list as local
References: <CAGoWm-Zd4x7MNh_+uKWKJ_tb7PjYVTdNVYF-uPQu1hmdP+_PQw@HIDDEN>
X-Spook: Steve Case Albright Palestine Liberation Organization
X-Ran: AS.g*^(_OE8E;%Q*&/q``7nmrg?9eg6<3z9cPr.dijU%QWK.4]%J=3`}L&bNHHfkIy'npD
X-Hue: black
X-Attribution: GM
Date: Tue, 27 Nov 2018 20:23:07 -0500
In-Reply-To: <CAGoWm-Zd4x7MNh_+uKWKJ_tb7PjYVTdNVYF-uPQu1hmdP+_PQw@HIDDEN>
 (Terje Larsen's message of "Sat, 24 Nov 2018 21:54:12 +0100")
Message-ID: <g74lc23shw.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: 33492
Cc: 33492 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.3 (-----)

Terje Larsen wrote:

> https://emacs.stackexchange.com/questions/3725/why-is-the-buffer-undo-list-excluded-from-buffer-local-variables
>
> I can verify that the issue stems from desktop-save relying on the
> C-function buffer-local-variables and this function does not include
> the variable buffer-undo-list.


Thanks for the report.
This issue (buffer-local-variables does not include buffer-undo-list)
is present since Emacs 24.3, due to 36429c8, which moved undo_list to
the end of struct buffer.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33492; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Nov 2018 20:54:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 24 15:54:37 2018
Received: from localhost ([127.0.0.1]:45830 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gQewm-000354-ON
	for submit <at> debbugs.gnu.org; Sat, 24 Nov 2018 15:54:37 -0500
Received: from eggs.gnu.org ([208.118.235.92]:54149)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <terlar@HIDDEN>) id 1gQewk-00034p-Bx
 for submit <at> debbugs.gnu.org; Sat, 24 Nov 2018 15:54:34 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <terlar@HIDDEN>) id 1gQewd-0000xq-R1
 for submit <at> debbugs.gnu.org; Sat, 24 Nov 2018 15:54:28 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:54880)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <terlar@HIDDEN>) id 1gQewd-0000xj-OL
 for submit <at> debbugs.gnu.org; Sat, 24 Nov 2018 15:54:27 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35514)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <terlar@HIDDEN>) id 1gQewc-0006yE-Hq
 for bug-gnu-emacs@HIDDEN; Sat, 24 Nov 2018 15:54:27 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <terlar@HIDDEN>) id 1gQewb-0000up-DA
 for bug-gnu-emacs@HIDDEN; Sat, 24 Nov 2018 15:54:26 -0500
Received: from mail-yw1-xc2f.google.com ([2607:f8b0:4864:20::c2f]:34848)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <terlar@HIDDEN>) id 1gQewb-0000uV-8G
 for bug-gnu-emacs@HIDDEN; Sat, 24 Nov 2018 15:54:25 -0500
Received: by mail-yw1-xc2f.google.com with SMTP id h32so6056889ywk.2
 for <bug-gnu-emacs@HIDDEN>; Sat, 24 Nov 2018 12:54:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to
 :content-transfer-encoding;
 bh=Lq5H6FdR9jpLiZx7M9KkYL4QMREtxMIGO4y/JasV/hw=;
 b=WGIBEwAKxQ97+OkiwGi+DPrB8Tir07V6CUoLKb2+7oG9ORKmuApaLMKqw3hHQVB0pe
 ph6f/9BLDDuByb5QTHHR+oNSRN43/EKicfiRDx32InZQIp8lom4ixh8okv2VVoqJstMz
 2b14aPDn6XoaK5GndWAuKp8xHSDKIqO81HBNe/fe3Gk9oZdlxDmpe9ZzG1PBjGyWiUOz
 EN5JsuHgrZKYf2wBranpGoW2qAc0qNqbFyRORF6RThYaKdRhC4/GeNUieOoLQTsEZ6Nd
 eZeZxyMCC41LZYBacXhDYgaqTWLqLrdS1um5WW0ZWJTOFdnvLIYqy4ekO3lY3c1s6loi
 1qpQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to
 :content-transfer-encoding;
 bh=Lq5H6FdR9jpLiZx7M9KkYL4QMREtxMIGO4y/JasV/hw=;
 b=n8FsCm3QUy413QwAJyHtjYtmY2zpjs4UET90TsoCVRtph326GtgFVIvi7JxO6uBNQq
 PXVtsW9FlW5k4xTYoc+xLRLvKynHOsVEI/005BXE9BW4znWDxoWlxn67Z6KscBjObzRs
 toPDS6+JzC4K+uhX2jqf8GD1i1I99NMUBnCbq5F+liIA7XAuTnLY+Tk9R0vHV5i4RVCO
 JM9WIgVXIzyhovqYglNgVcFKJBgaLZqFgbx5EMTn7Ru1q7qV3ikKL4uIOD/+Awp8ojuX
 5IdEFwCEF/ajfjd1o3JTo+0WxUmLObYTityVKh/HMmSJWMNHZNNd7T5iix22R1JiuQHE
 ZF3Q==
X-Gm-Message-State: AGRZ1gLNfNQ3aDf83Q4AAYNz96UiI86OJcUUJlhi0C9zfycS5Xb0RAjk
 2TIamaD/gMlJ0e3f5CG4x+gpZkU1kxVcW5IQz9/eqGvVt1s=
X-Google-Smtp-Source: AJdET5fZ67Xz2hO85JJvs50vscXs9ifDSxd/KHTmcDKQZ7f1iYiKgzc1YsIurf1ofDvHLNmM/zGFvCyxRI2uPi8eGLE=
X-Received: by 2002:a0d:ca43:: with SMTP id m64mr22679337ywd.145.1543092864213; 
 Sat, 24 Nov 2018 12:54:24 -0800 (PST)
MIME-Version: 1.0
From: Terje Larsen <terlar@HIDDEN>
Date: Sat, 24 Nov 2018 21:54:12 +0100
Message-ID: <CAGoWm-Zd4x7MNh_+uKWKJ_tb7PjYVTdNVYF-uPQu1hmdP+_PQw@HIDDEN>
Subject: 27.0.50;
 desktop-locals-to-save won't consider buffer-undo-list as local
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Add buffer-undo-list to be saved by desktop-save:
(cl-pushnew 'buffer-undo-list desktop-locals-to-save :test #'equal)

Open a file:
C-x C-f ~/sample.txt

Input text such as:
Lorem ipsum dolor sit amet

Remove the two last words:
M-2 M-DEL

Save the desktop:
M-x desktop-save

... Restart Emacs ...

Load the desktop:
M-x desktop-read

Execute undo operation:
C-/

At this point I expect the undo operations from the previous session
to be successful.

It seems like this has been mentioned at StackExchange amongst other
places before:
https://emacs.stackexchange.com/questions/3725/why-is-the-buffer-undo-list-=
excluded-from-buffer-local-variables

I can verify that the issue stems from desktop-save relying on the C-functi=
on
buffer-local-variables and this function does not include the variable
buffer-undo-list.
Due to this it will be ignored from being saved by the desktop-save command=
.

Proposed in the StackExchange post is to append the buffer-undo-list
in the desktop-save
function. But perhaps it should be included in the C-function? Or does
that perhaps cause
other issues?

Personally I have solved it by using an advice:

(defun +append-buffer-undo-list-to-buffer-local-variables-advice
(orig-fn &rest args)
       "Override `buffer-local-variables' and call ORIG-FN with ARGS.
     There is a bug in Emacs where the `buffer-undo-list' data is
     missing from the output of `buffer-local-variables'. This
     advice temporarily overrides the function and appends the
     missing data."
       (let ((orig-buffer-local-variables-fn (symbol-function
'buffer-local-variables)))
         (cl-letf (((symbol-function 'buffer-local-variables)
                    #'(lambda () (append (funcall
orig-buffer-local-variables-fn)
                                    `(,(cons 'buffer-undo-list
buffer-undo-list))))))
           (apply orig-fn args))))
(advice-add #'desktop-buffer-info :around
#'+append-buffer-undo-list-to-buffer-local-variables-advice)

I hope this "long-standing" bug would allow more people to utilize a
persistent undo without
jumping through hoops.

Thanks!


In GNU Emacs 27.0.50 (build 2, x86_64-apple-darwin18.0.0, NS
appkit-1671.00 Version 10.14 (Build 18A391))
of 2018-11-07 built on C02V91MHHV2Q.local
Repository revision: 811d9291fcfb12d87bad277d4e8b25152129d73d
Windowing system distributor 'Apple', version 10.3.1671
System Description:  Mac OS X 10.14.1

Recent messages:
Desktop: 1 frame, 1 buffer restored.
You can run the command =E2=80=98desktop-read=E2=80=99 with M-x d-rea RET
Desktop: 1 frame, 1 buffer restored.
user-error: No further undo information [2 times]
user-error: Beginning of history; no preceding item
user-error: End of history; no default available

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=3D/usr/local/share/emacs/site-lisp
--infodir=3D/usr/local/Cellar/emacs/HEAD-811d929_1/share/info/emacs
--prefix=3D/usr/local/Cellar/emacs/HEAD-811d929_1 --with-gnutls
--without-x --with-xml2 --without-dbus --with-imagemagick --with-rsvg
--with-ns --disable-ns-self-contained'

Configured features:
RSVG IMAGEMAGICK GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS NS THREADS LCMS2 GMP

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils thingatpt cl-seq cl-extra
help-mode easymenu desktop frameset cl-loaddefs cl-lib elec-pair tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue cocoa ns
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 208523 10884)
(symbols 48 20326 1)
(strings 32 30075 1669)
(string-bytes 1 808523)
(vectors 16 35932)
(vector-slots 8 729980 19992)
(floats 8 51 198)
(intervals 56 240 0)
(buffers 992 13))




Acknowledgement sent to Terje Larsen <terlar@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#33492; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 30 Jan 2019 00:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.