Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs, namespaces and defuns

Tags:

emacs

elisp

The only thing I don't like about Emacs is the lack of namespaces, so I'm wondering if I can implement them on my own.

This is my first attempt, and it's obvious that I can't just replace every match of a name with its prefixed version, but what should I check? I can check for bindings with (let) then mark the entire subtree, but what if somebody creates a (my-let) function that uses let? Is my effort destined to fail? :(

Also, why are my defuns failing to define the function? Do I have to run something similar to intern-symbol on every new token?

Thanks!

like image 900
konr Avatar asked Dec 10 '10 15:12

konr


3 Answers

Since this is the first google result for elisp namespaces...

There's a minimalist implementation of namespaces called fakespace which you can get on elpa, which does basic encapsulation. I'm working on something ambitious myself, which you can check out here.

like image 95
Chris Barrett Avatar answered Oct 11 '22 04:10

Chris Barrett


To handle things like my-let or my-defun, you need to macroexpand those definitions, e.g. with macroexpand-all.

For the failure to define the functions, you need to use intern instead of make-symbol (because make-symbol always creates a new distinct fresh uninterned symbol).

like image 29
Stefan Avatar answered Oct 11 '22 02:10

Stefan


Adding namespaces will take more than prefixing the identifiers with the namespace names. The interpreter has to be able to tell the namespaces. Some tinkering must go into the interpreter as well. That might need to go through a thorough discussion at gnu.emacs.sources and/or #emacs at irc.freenode.org.

like image 24
vpit3833 Avatar answered Oct 11 '22 02:10

vpit3833