unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Carsten Dominik <dominik@science.uva.nl>
To: help-gnu-emacs@gnu.org
Subject: Circular require
Date: Thu, 13 Mar 2008 14:22:58 +0100	[thread overview]
Message-ID: <m2tzja3gi5.fsf@nb-dominik2.science.uva.nl> (raw)


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	other threads:[~2008-03-13 13:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-13 13:22 Carsten Dominik [this message]
2008-03-13 20:11 ` Circular require Leo
2008-03-13 23:41   ` Lennart Borgman (gmail)
2008-03-14 12:54     ` Carsten Dominik
2008-03-14 12:53   ` Carsten Dominik

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2tzja3gi5.fsf@nb-dominik2.science.uva.nl \
    --to=dominik@science.uva.nl \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).