Hmm, well, it was a nice idea, but it fails, as the eval happens before
the load. Can't quite work out why this is true, but it is.

Far as I can tell, this requires Java level changes. Or I can provide
support in the package.

Shame.

Phil

Phillip Lord <phillip.l...@newcastle.ac.uk> writes:

> Well, yes, but it always does it and needs modification of the source.
>
> Anyway, I found a solution; requires usage of a private var,
> unfortunately, but it does work.
>
>
> (defn eval-after-load [library form]
>   (let [key
>         (keyword
>          (str "eval-after-load-" library))]
>     (add-watch
>      (var-get #'clojure.core/*loaded-libs*) key
>      (fn[key ref old new]
>        (when (= library
>                 (first (clojure.set/difference new old)))
>          (eval form))))
>     library))
>
> (eval-after-load
>     'bob
>     '(println "Hello Bob!"))
>
>
> Cedric Greevey <cgree...@gmail.com> writes:
>
>> Doesn't simply putting some executable forms at the end of the namespace's
>> source code do that? e.g.
>>
>> (ns foo
>>   ...)
>>
>> (defn ...)
>>
>> (def ...)
>>
>> (defn ...)
>>
>> ...
>>
>> (do-something!)
>>
>>
>>
>> On Mon, Oct 28, 2013 at 1:05 PM, Phillip Lord
>> <phillip.l...@newcastle.ac.uk>wrote:
>>
>>>
>>> I want to add some additional configuration after I have loaded a
>>> library. Is there anything equivalent to eval-after-load in emacs, which
>>> enables me to do something after a namespace has been loaded? Or a file?
>>>
>>> Phil
>>>
>>> --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>> -- 
>
> -- 
> Phillip Lord,                           Phone: +44 (0) 191 222 7827
> Lecturer in Bioinformatics,             Email: phillip.l...@newcastle.ac.uk
> School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord
> Room 914 Claremont Tower,               skype: russet_apples
> Newcastle University,                   twitter: phillord
> NE1 7RU                                 
>
> -- 

-- 
Phillip Lord,                           Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics,             Email: phillip.l...@newcastle.ac.uk
School of Computing Science,            
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,               skype: russet_apples
Newcastle University,                   twitter: phillord
NE1 7RU                                 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to