all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: 33492@debbugs.gnu.org
Cc: Terje Larsen <terlar@gmail.com>
Subject: bug#33492: 27.0.50; desktop-locals-to-save won't consider buffer-undo-list as local
Date: Tue, 29 Jan 2019 19:30:58 -0500	[thread overview]
Message-ID: <rg8sz3yojh.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <bb7egwvpo1.fsf@fencepost.gnu.org> (Glenn Morris's message of "Wed, 28 Nov 2018 16:49:02 -0500")

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.





  reply	other threads:[~2019-01-30  0:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-24 20:54 bug#33492: 27.0.50; desktop-locals-to-save won't consider buffer-undo-list as local Terje Larsen
2018-11-28  1:23 ` Glenn Morris
2018-11-28 21:49   ` Glenn Morris
2019-01-30  0:30     ` Glenn Morris [this message]
2020-05-18 17:57       ` Glenn Morris

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=rg8sz3yojh.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=33492@debbugs.gnu.org \
    --cc=terlar@gmail.com \
    /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.