all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Glenn Morris <rgm@gnu.org>
Cc: Lawrence Mitchell <wence@gmx.li>, emacs-devel@gnu.org
Subject: Finding a variable before it's loaded
Date: Thu, 23 Feb 2012 16:48:56 -0500	[thread overview]
Message-ID: <jwvvcmxp728.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <ge4nuh1nde.fsf@fencepost.gnu.org> (Glenn Morris's message of "Thu, 23 Feb 2012 12:16:29 -0500")

>> 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 <foo>-<bar>, look for a file <foo>.el or
<foo>-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



  parent reply	other threads:[~2012-02-23 21:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 17:17 bug#10868: 24.0.93; `comment-style' needs to be explained Drew Adams
2012-02-22 17:38 ` Glenn Morris
2012-02-22 18:06   ` Drew Adams
2012-02-22 18:11     ` Glenn Morris
2012-02-22 19:01       ` Drew Adams
2012-02-23  9:22         ` Lawrence Mitchell
2012-02-23 14:31           ` Stefan Monnier
2012-02-23 15:35             ` Drew Adams
2012-02-23 16:04               ` Stefan Monnier
2012-02-23 16:13                 ` Drew Adams
2012-02-25  3:08             ` Chong Yidong
2012-02-23 17:16           ` Glenn Morris
2012-02-23 17:22             ` Glenn Morris
2012-02-23 17:24             ` Lawrence Mitchell
2012-02-23 17:34             ` Drew Adams
2012-02-23 21:48             ` Stefan Monnier [this message]
2012-02-23 22:29               ` Finding a variable before it's loaded Lennart Borgman

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=jwvvcmxp728.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=rgm@gnu.org \
    --cc=wence@gmx.li \
    /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.