[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33492: 27.0.50; desktop-locals-to-save won't consider buffer-undo-li
From: |
Glenn Morris |
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 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#33492: 27.0.50; desktop-locals-to-save won't consider buffer-undo-list as local,
Glenn Morris <=