From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: How to debug modification to a variable value? Date: Wed, 27 Jan 2010 08:50:46 +0100 Message-ID: <87aaw0asvd.fsf@thinkpad.tsdh.de> References: <87636pvrdj.fsf@thinkpad.tsdh.de> <52428.130.55.118.19.1264458645.squirrel@webmail.lanl.gov> <87636p5k9u.fsf@thinkpad.tsdh.de> <45732.130.55.118.19.1264539889.squirrel@webmail.lanl.gov> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1264578700 13865 80.91.229.12 (27 Jan 2010 07:51:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Jan 2010 07:51:40 +0000 (UTC) Cc: emacs-devel@gnu.org To: herring@lanl.gov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 27 08:51:33 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Na2gW-00053u-7O for ged-emacs-devel@m.gmane.org; Wed, 27 Jan 2010 08:51:32 +0100 Original-Received: from localhost ([127.0.0.1]:58644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Na2gW-0001mg-OS for ged-emacs-devel@m.gmane.org; Wed, 27 Jan 2010 02:51:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Na2fy-0001lq-Ro for emacs-devel@gnu.org; Wed, 27 Jan 2010 02:50:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Na2fr-0001kP-On for emacs-devel@gnu.org; Wed, 27 Jan 2010 02:50:55 -0500 Original-Received: from [199.232.76.173] (port=44856 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Na2fq-0001kH-S1 for emacs-devel@gnu.org; Wed, 27 Jan 2010 02:50:51 -0500 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:15054) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Na2fq-00071z-7s for emacs-devel@gnu.org; Wed, 27 Jan 2010 02:50:50 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 4FF4D7811250; Wed, 27 Jan 2010 08:50:49 +0100 (CET) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08133-01; Wed, 27 Jan 2010 08:50:47 +0100 (CET) X-CHKRCPT: Envelopesender noch tassilo@member.fsf.org Original-Received: from thinkpad.tsdh.de (wlan-135.uni-koblenz.de [141.26.93.135]) by deliver.uni-koblenz.de (Postfix) with ESMTP id C9823789745F; Wed, 27 Jan 2010 08:50:46 +0100 (CET) Mail-Followup-To: herring@lanl.gov, emacs-devel@gnu.org In-Reply-To: <45732.130.55.118.19.1264539889.squirrel@webmail.lanl.gov> (Davis Herring's message of "Tue, 26 Jan 2010 13:04:49 -0800 (PST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) X-Virus-Scanned: amavisd-new at uni-koblenz.de X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:120485 Archived-At: "Davis Herring" writes: Hi Davis, >> So tg-mode contains >> [...] >> 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. > > Aha! Now we can ignore most of what I've written so far (except perhaps > for reference for future bugs). > > `tg-init-schema' also sets `tg-schema-alist', of course; that's how > `greql-set-graph' gets it. And I see that `tg-eldoc-init' adds that > function to `after-save-hook' (globally!), Indeed, that's wrong. Now it's only added to `after-save-hook' locally. > and that `tg-initialize' adds -that- to `eldoc-mode-hook' (globally!), > and that `tg-mode' calls -that-. No, `tg-eldoc-init' is added locally, but I guess you mean that as a result, `tg-init-schema' ends up globally in `after-save-hook' as soon as `eldoc-mode-hook' was run, and you are right. > While greql-mode.el never actually invokes `tg-mode' for you, I suspect > that at some point your Emacs did run `tg-mode', which called > `tg-initialize', which registered `tg-eldoc-init', which got called > (perhaps in some other buffer) by `eldoc-mode' and registered > `tg-init-schema', which got called by `basic-save-buffer' in your GReQL > buffer. This non-local, delayed effect probably does look a lot like > magic and probably does only happen in some Emacs sessions. > > Am I right? Absolutely. How much time did you spend on that, and how did you debug it? Using a watchpoint in gdb as you suggested? While I clearly see that the global `add-hook' is plain wrong, I wouldn't have found it by looking carefully at the code. Thanks a lot, I evaled (cons "Davis Herring" list-of-extremely-helpful-guys). Bye, Tassilo