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: special forms (save-excursion)


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

> Should the macros be in module (emacs import), if they correspond to
> Emacs features?

A new module (emacs macro) might be better.

> If it were possible to pass Scheme procedure objects to Emacs Lisp and
> call them from there, save-excursion could use the existing primitive:
> 
> (define-syntax save-excursion
>   (syntax-rules ()
>     ((save-excursion body ...)
>      (emacs-eval `(save-excursion
> 		     (,(lambda ()
> 			  body ...)))))))

Well, in this way, you can't write this:

(let ((start (point)))
  (save-excursion
    (goto-char start)))

> Here's another version which uses guile-eval instead of directly
> calling the procedure from Emacs.  But it too needs the new type.
> 
> (define-syntax save-excursion
>   (syntax-rules ()
>     ((save-excursion body ...)
>      (emacs-eval `(save-excursion
> 		     (guile-eval '(',(lambda ()
> 				        body ...))))))))

This looks better in this case.  Probably many of Lisp macros can be
implemented this way, except some others such as `unwind-protect'
(but we already have `dynamic-wind').  I guess I should add the new
Lisp type, but... a problem can be we have to convert Scheme's #t
and #f into the special type instead of t and nil.  But this may
not be a problem since we can return a symbol t or nil to Lisp anyway.
(And it can be done automatically in some way.)

OK, I'll try to add the type soon.  I guess you can define a new
macro `import-lisp-macro'.

> You wrote you'd rename emacs-eval and emacs-apply.
> What are the new names?

New primitives will be:

  lisp-eval, lisp-apply, scheme-eval, scheme-apply

New Scheme procedures/macros will be:

  lisp-true?, lisp-false?,
  lisp-variable-ref, lisp-variable-set!,
  import-lisp-function, import-lisp-variable

and perhaps:

  define-global-varialbe, define-command

In addition, I could implement import-scheme-procedure or something
for Emacs Lisp.

Hopefully I am releasing the next version within today.

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