From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Finding a variable before it's loaded Date: Thu, 23 Feb 2012 16:48:56 -0500 Message-ID: References: <7AF76478FD534B8B9A07E9FB79060E64@us.oracle.com> <5b4nuizqj9.fsf@fencepost.gnu.org> <3251750A293C4D74AAB64FD8672192CE@us.oracle.com> <87ehtlykdr.fsf@gmx.li> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1330033759 7622 80.91.229.3 (23 Feb 2012 21:49:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 23 Feb 2012 21:49:19 +0000 (UTC) Cc: Lawrence Mitchell , emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 23 22:49:10 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S0gXB-0005uK-DE for ged-emacs-devel@m.gmane.org; Thu, 23 Feb 2012 22:49:05 +0100 Original-Received: from localhost ([::1]:38503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0gXA-0000SD-HE for ged-emacs-devel@m.gmane.org; Thu, 23 Feb 2012 16:49:04 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:46246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0gX8-0000Rw-21 for emacs-devel@gnu.org; Thu, 23 Feb 2012 16:49:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0gX6-0007de-Qx for emacs-devel@gnu.org; Thu, 23 Feb 2012 16:49:02 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:42020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0gX5-0007dP-BD; Thu, 23 Feb 2012 16:48:59 -0500 Original-Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q1NLmuVk016776; Thu, 23 Feb 2012 16:48:56 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 8D565B4467; Thu, 23 Feb 2012 16:48:56 -0500 (EST) In-Reply-To: (Glenn Morris's message of "Thu, 23 Feb 2012 12:16:29 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4141=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4141> : streams <731616> : uri <1071006> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:148753 Archived-At: >> The docstring of comment-style refers the user to comment-styles for >> details on what the values mean. However, this is not available until >> after newcomment.el is loaded. So autoload comment-styles to avoid >> this problem. > Then this is an instance of a general problem. See eg > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1768 > for the same thing. > IMO there should be a general solution rather than papering over every > instance that occurs with more pre/autoloading. Yes, there is a general problem underneath, but it's difficult to solve satisfactorily. IIRC someone did submit a potential solution at some point, but it required building a fairly large file listing where each var is defined. I have toyed with a slightly different approach which tries to reduce the size of this file by keeping not the list of all vars, but only a list of prefixes used by each file. This way, if I want to find `comment-styles', I can simply load all the files that define variables with the "comment-" prefix. The table of prefixes is not very large, so I can simply have it preloaded and put it in loaddefs.el (and it's automatically maintained by autoload.el, which means it can also work for non-bundled packages if their autoloads are generated by autoload.el). E.g. for newcomment.el my code adds: (register-definition-prefixes "newcomment" '("comment-" "uncomment-region-function" "uncomment-region-default" "block-comment-start" "block-comment-end")) and for diff-mode.el it doesn't add anything at all, because I use a default rule "for -, look for a file .el or -mode.el" and that covers all the definitions in diff-mode.el. It's also fun to look at all the register-definition-prefixes in loaddefs.el as a way to flag "unclean namespace issues". Stefan