[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to debug modification to a variable value?
From: |
Tassilo Horn |
Subject: |
Re: How to debug modification to a variable value? |
Date: |
Tue, 26 Jan 2010 09:43:09 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) |
"Davis Herring" <address@hidden> writes:
Hi Davis,
>> Now, my problem was that under some circumstances after saving, the
>> buffer-local value of `tg-schema-alist' was gone, i.e. set to nil.
>
> There's a difference between "gone" and "set to nil", even for
> automatically-buffer-local variables. Does it still have a
> buffer-local value (which is wrong), or is it using the default
> (again)? C-h v will say.
"Gone" means, it has the buffer-local value nil. So there seems to be
no call to `kill-local-variable'.
>> I double-checked `greql-set-fontlock-types-regex' that it doesn't
>> modify `tg-schema-alist', and it doesn't. I also removed all
>> destructive function calls in there, although it operates only on a
>> list created by `mapcar', and that's a copy anyway, right?
>
> Destructive operations on lists can't set the value of a variable to nil,
> nor can they invoke `kill-local-variable'. `set[qf]?' is of course
> destructive, as are `kill-local-variable' and `kill-all-local-variables';
> have you looked for all of those?
There's no `kill-[all-]local-variable[s]', and the `setq' of that
variable is isolated in one command (see end of this message), which is
never called internally, only by a keybinding.
>> So what I need is some way to be put in the debugger when the value
>> of `tg-schema-alist' is modified. Is that feasible? I tried adding
>> an after advice to `setq' which does exactly that, but that screwed
>> my emacs instance. I guess it's no good idea to advice such
>> primitives...
>
> I don't that you can do this in the Emacs debugger, but you should be
> able to use a watchpoint in gdb for this purpose. Find where the
> buffer-local value of the variable is stored, set the watchpoint, and
> then save.
Sounds good, but how do I do that? Especially the "find where the
buffer-local value of the variable is stored" part...
> Meanwhile, my psychic powers suggest that you have a `let' binding of
> the variable in question and switch buffers within the `let', or else
> that something is reasserting your major mode so that
> `kill-all-local-variables' is getting called.
Hm, the problem occured while I was using many different frames, which I
didn't use till now, so something in this direction seems possible. But
between the variable is set buffer-locally to some alist and the
variable is set buffer-locally to nil, there was only one C-x C-s
without switching frames/buffers at all.
> You could test for the latter with the `permanent-local' property.
Oh, I didn't know that property.
,----[ (info "(elisp)Creating Buffer-Local") ]
| A buffer-local variable is "permanent" if the variable name (a
| symbol) has a `permanent-local' property that is non-`nil'. Permanent
| locals are appropriate for data pertaining to where the file came from
| or how to save it, rather than with how to edit the contents.
`----
I don't know if this is appropriate for `tg-schema-alist'. It
determines the completion possibilities and highlighting, and is not
strictly related to the current buffer/file, but to another file a user
can select and switch.
> PS - Sorry if some of these instructions are obvious;
They are not, at least to me. So thanks a lot!
> I don't know just what you know!
Sure, I just wantet to avoid posting the whole code, if not absolutely
neccessary. It's free sofware, and you can svn checkout it from [1]
using anonymous/secret as user/password.
But basically, there are two modes: tg-mode has a simple parser for a
schema description language, and greql-mode which is a mode for a graph
query language, which is used for querying graphs conforming to some TG
schema.
So tg-mode contains
--8<---------------cut here---------------start------------->8---
(defvar tg-schema-alist nil
"The schema of the current TG file.")
(make-variable-buffer-local 'tg-schema-alist)
--8<---------------cut here---------------end--------------->8---
and in greql-mode (which requires tg-mode), there is the only function
modifying the value of `tg-schema-alist' by assigning the buffer-local
value of a temporary buffer to the buffer-local value in the query
buffer.
--8<---------------cut here---------------start------------->8---
(defun greql-set-graph (graph)
"Set `greql-graph' to GRAPH and parse it with `tg-parse-schema'."
(interactive "fGraph file: ")
(setq greql-graph graph)
(let ((g greql-graph)
schema-alist unique-name-map)
(with-temp-buffer
(insert-file-contents g)
(tg-init-schema)
(setq schema-alist tg-schema-alist)
(setq unique-name-map tg-unique-name-hashmap))
(setq tg-schema-alist schema-alist)
(setq tg-unique-name-hashmap unique-name-map))
;; Setup schema element font locking
(greql-set-fontlock-types-regex))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
__________
[1] https://svn.uni-koblenz.de/ist/projects/jgralab/trunk/utils
- RE: How to debug modification to a variable value?, (continued)
Re: How to debug modification to a variable value?, Davis Herring, 2010/01/25
- Re: How to debug modification to a variable value?,
Tassilo Horn <=
Re: How to debug modification to a variable value?, alin.s, 2010/01/26