From: Tassilo Horn <tassilo@member.fsf.org>
To: herring@lanl.gov
Cc: emacs-devel@gnu.org
Subject: Re: How to debug modification to a variable value?
Date: Tue, 26 Jan 2010 09:43:09 +0100 [thread overview]
Message-ID: <87636p5k9u.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: <52428.130.55.118.19.1264458645.squirrel@webmail.lanl.gov> (Davis Herring's message of "Mon, 25 Jan 2010 14:30:45 -0800 (PST)")
"Davis Herring" <herring@lanl.gov> 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
next prev parent reply other threads:[~2010-01-26 8:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-25 20:52 How to debug modification to a variable value? Tassilo Horn
2010-01-25 21:08 ` Drew Adams
2010-01-26 8:00 ` Tassilo Horn
2010-01-26 15:17 ` Stefan Monnier
2010-01-26 16:49 ` Richard Stallman
2010-01-26 21:02 ` Stefan Monnier
2010-01-26 18:02 ` alin.s
2010-01-27 7:37 ` Andreas Roehler
2010-01-27 8:24 ` Tassilo Horn
2010-01-27 8:51 ` Andreas Roehler
2010-01-25 22:30 ` Davis Herring
2010-01-26 8:43 ` Tassilo Horn [this message]
2010-01-26 21:04 ` Davis Herring
2010-01-27 7:50 ` Tassilo Horn
2010-01-27 15:42 ` Davis Herring
2010-01-26 15:52 ` alin.s
2010-01-26 20:26 ` Tassilo Horn
2010-01-27 8:13 ` alin.s
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=87636p5k9u.fsf@thinkpad.tsdh.de \
--to=tassilo@member.fsf.org \
--cc=emacs-devel@gnu.org \
--cc=herring@lanl.gov \
/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.