This is the mail archive of the guile-emacs@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: import-lisp-macro


Kalle Olavi Niemitalo <tosi@ees2.oulu.fi> writes:

> The current version (emacs.scm 1.3) of import-lisp-macro can't
> handle this:
> (let ((msg "Hello!"))
>   (save-excursion
>     msg))
> because it evaluates the lambda in the wrong place.

That's right.

> The following definition seems to work better.  I moved most of
> the code emitted by the macro to a new function "call-lisp-macro"
> because nested backquotes confuse me.  There is still some
> nesting; I hope I got it right.  I am currently unable to access
> SourceForge via SSH so please commit this change for me.
> (You could use this mail as the log message. :-) )
> 
> (define-private (call-lisp-macro macro-name thunk)
>   (lispref->scm (lisp-eval `(,macro-name
> 			      (scheme-eval '(',thunk))))))
> 
> (define-macro (import-lisp-macro macro . rest)
>   (let ((scheme-name (if (pair? rest) (car rest) macro)))
>     `(define-macro (,scheme-name . body)
>        `(',',call-lisp-macro ',',macro (lambda () ,@body)))))
> (export import-lisp-macro)

Thanks.  I'll commit this soon.  Could you extend this so that it
handles with-current-buffer properly?  Maybe defining a new macro
import-lisp-macro-1 is better.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]