help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Circular require


From: Carsten Dominik
Subject: Circular require
Date: Thu, 13 Mar 2008 14:22:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (darwin)

Hi,

I have a question about the setup of a package that eventually will
consists of many files (we are talking about org-mode...).

In this package I have a number of files that implement certain
funtionality, and I can use autoload or a well-placed `require'
statement in the code to get the code loaded when I want.

A separate class of files implements optional code that the user might
or might not want to use.  Because it is an option, I cannot autoload
the code.  I can tell the user to do a (require ...) for
the corresponding feature in .emacs to get things loaded.

However, I am not entirely happy with this setup.

1. I would like to make it easy for the user to get an overview over the
   possible extensions and make it a simple mouse-clock selection in a
   customize variabe to get this features loaded.

2. Each of these small add-ons contains a (require 'org), which means
   that loading this add-on will also load org.el and the whole
   stuff, even into an emacs sesstion where we will not use org-mode at
   all. 

So the kind of setup I had in mind is this


(defcustom org-default-extensions '(org-irc)
  "Extensions that should always be loaded together with org.el.
If the description starts with <A>, this means the extension
will be autoloaded when needed, preloading is not necessary.
FIXME: this does not ork correctly, ignore it for now."
  :group 'org
  :type
  '(set :greedy t
        (const :tag "    Mouse support (org-mouse.el)" org-mouse)
        (const :tag "<A> Publishing (org-publish.el)" org-publish)
        (const :tag "<A> LaTeX export (org-export-latex.el)" org-export-latex)
        (const :tag "    IRC/ERC links (org-irc.el)" org-irc)
        (const :tag "    Apple Mail message links under OS X 
(org-mac-message.el)" org-mac-message)))

(defun org-load-default-extensions ()
  "Load all extensions listed in `org-default-extensions'."
  (mapc (lambda (ext) 
          (condition-case nil (require ext)
            (error (message "Problems while trying to load feature `%s'" ext))))
        org-default-extensions))


Then do as the last thing in org.el

(provide 'org)
(org-load-default-extensions)

This is all nice, and works will upon load time.  However, during
compilation it leads to problems, because the extension will be *loaded*
while Emacs is trying to compile it.  This happens because the
compilation executed the (require 'org), which in turn tries to require
the extension.

So finally, here is my question.  Does anyone have a good idea how to
deal with such a setup?  Or is what I am trying to do not something that
can/should be done?

Thanks a bunch.

- Carsten


reply via email to

[Prev in Thread] Current Thread [Next in Thread]