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)


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> Well, in this way, you can't write this:
> 
> (let ((start (point)))
>   (save-excursion
>     (goto-char start)))

Why not?  It's expanded to:

(let ((start (point)))
  (emacs-eval `(save-excursion
                 (,(lambda ()
                     (goto-char start))))))

The lambda form is evaluated in the Scheme side because of the
comma, and it captures the current lexical environment like
Scheme procedures always do.  When Emacs calls the closure, Guile
uses the captured binding of start.

Or, that's how I think it would work.  :-)

The Emacs evaluator would have to be changed to call the
equivalent of guile-apply if the function being called is a
Scheme object.  I don't know how difficult that is.  If it is too
much work, the version with an explicit guile-eval could be used.
This is really the only difference between the versions.

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

That could be used for all the `save-' macros / special forms.
But others like `when' and `condition-case' take their parameters
in different ways and would have to be handled separately.
Perhaps the importing macro should be called
`import-lisp-body-macro' because it applies only to macros whose
parameters form a single body.  Then there could be
`import-lisp-1-body-macro' for things like `with-current-buffer'
which take one normal parameter and a body.

Should I use defmacro instead of syntax-rules?  I like
syntax-rules more, but it seems slower.

How do I define documentation strings for Guile macros?

>   lisp-variable-ref, lisp-variable-set!,
>   import-lisp-function, import-lisp-variable

Are they used like this?
(lisp-variable-set! (import-lisp-variable 'buffer-read-only) 't)

I think import-* and export-* names should be used for functions
which actually change bindings of symbols, not only return a
reference to the variable.  `lisp-function' would be enough for
that.

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