unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Finding a variable before it's loaded
       [not found]           ` <ge4nuh1nde.fsf@fencepost.gnu.org>
@ 2012-02-23 21:48             ` Stefan Monnier
  2012-02-23 22:29               ` Lennart Borgman
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2012-02-23 21:48 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Lawrence Mitchell, emacs-devel

>> 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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Finding a variable before it's loaded
  2012-02-23 21:48             ` Finding a variable before it's loaded Stefan Monnier
@ 2012-02-23 22:29               ` Lennart Borgman
  0 siblings, 0 replies; 2+ messages in thread
From: Lennart Borgman @ 2012-02-23 22:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Lawrence Mitchell

On Thu, Feb 23, 2012 at 22:48, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> 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 did that. Though I did not have time to finish it in the end.
However the timing was not a big problem. The table size was perhaps a
problem.

> 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.

Sounds like a better solution.

> This way, if I want to find `comment-styles', I can simply load all the files
> that define variables with the "comment-" prefix.

Could not that be problematic? Maybe the build process could warn if a
prefix is found in the wrong file?



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-23 22:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <DB139E6F33CC441B9C3798B66C9D52FE@us.oracle.com>
     [not found] ` <bnhayi4vl5.fsf@fencepost.gnu.org>
     [not found]   ` <7AF76478FD534B8B9A07E9FB79060E64@us.oracle.com>
     [not found]     ` <5b4nuizqj9.fsf@fencepost.gnu.org>
     [not found]       ` <3251750A293C4D74AAB64FD8672192CE@us.oracle.com>
     [not found]         ` <87ehtlykdr.fsf@gmx.li>
     [not found]           ` <ge4nuh1nde.fsf@fencepost.gnu.org>
2012-02-23 21:48             ` Finding a variable before it's loaded Stefan Monnier
2012-02-23 22:29               ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).