Malabarba / names

A Namespace implementation for Emacs-Lisp
250 stars 19 forks source link

Possible enhancement - Macro to remove package boilerplate to function calls? #11

Open stubillwhite opened 9 years ago

stubillwhite commented 9 years ago

First of all, thank you so much for your work on this -- it's a huge boon and I'm thoroughly enjoying using it in my novice Emacs code.

One possible enhancement that I'd love would be some sort of "import" macro that would enable clients of a particular package to write code without the package prefix boilerplate on all of the functions.

For example, rather than writing:

    (sbw/my-package-function-one "Do something")
    (sbw/my-package-function-two "Do something else")

It would be lovely to be able to do something like:

    (import
      (sbw/my-package- '(function-one function-two))

      (function-one "Do something")
      (function-two "Do something else"))

And have the import macro prepend the my-package- prefix to the named symbols in the body of the macro.

Would something like that be in scope for the project and perhaps useful to others?

Malabarba commented 9 years ago

Yes, something like that would definitely be in scope. It's something I've been thinking about a lot, I just haven't got around to it yet.

The way I envisage it would be slightly different. Instead of a new macro, you could have pass a keyword to the define-namespace macro:

(define-namespace this-package-
:import cl-
:import (my-package- function-one function-two)

)

This would import everything that starts with cl-, and would also import function-one and function-two from my-package.

mwfogleman commented 9 years ago

Artur's version would make :import identical to :use in Clojure. Might be worth borrowing the convention, as it's fewer characters.

http://conj.io/store/org.clojure/clojure/1.6.0/clojure.core/ns/

Malabarba commented 9 years ago

@mwfogleman Sure, the simpler the better. I've been thinking of doing something like :require as well.