Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Toss the goofy lexical defmacro thing.

  • Loading branch information...
commit d1bd1f4b14b2690d7a67f9a52622ec51ed84813a 1 parent 4488ac7
@skeeto authored
Showing with 17 additions and 15 deletions.
  1. +17 −15 fakespace.el
View
32 fakespace.el
@@ -1,4 +1,4 @@
-;;; fakespace.el --- fake Emacs lisp namespaces -*- lexical-binding: t; -*-
+;;; fakespace.el --- fake namespaces with defpackage
;; This is free and unencumbered software released into the public domain.
@@ -63,20 +63,22 @@ items that are in B and not A."
(setq b (cdr b)))
diff))
-(let ((old-obarray ()))
- (defmacro defpackage (name &rest args)
- (dolist (arg args)
- (let ((type (car arg)))
- (cond ((eq type :exports) t) ; interning the symbols is enough
- ((eq type :use) (mapc (lambda (s) (require s)) (cdr arg))))))
- (setq old-obarray (fakespace--atom-list))
- `(provide (quote ,name)))
-
- (defmacro end-package ()
- (cons 'progn
- (mapcar (lambda (s) `(unintern (quote ,s) nil))
- (fakespace--atom-difference old-obarray
- (fakespace--atom-list))))))
+(defvar fakespace--obarray ()
+ "Snapshot of the obarray before interning the package's symbols.")
+
+(defmacro defpackage (name &rest args)
+ (dolist (arg args)
+ (let ((type (car arg)))
+ (cond ((eq type :exports) t) ; interning the symbols is enough
+ ((eq type :use) (mapc (lambda (s) (require s)) (cdr arg))))))
+ (setq fakespace--obarray (fakespace--atom-list) )
+ `(provide (quote ,name)))
+
+(defmacro end-package ()
+ (cons 'progn
+ (mapcar (lambda (s) `(unintern (quote ,s) nil))
+ (fakespace--atom-difference fakespace--obarray
+ (fakespace--atom-list)))))
(provide 'fakespace)
Please sign in to comment.
Something went wrong with that request. Please try again.