From: Kalle Olavi Niemitalo <tosi@stekt.oulu.fi>
To: Keisuke Nishida <kxn30@po.cwru.edu>
Cc: guile-emacs@sourceware.cygnus.com
Subject: Re: Emacs Scheme interface
Date: Wed, 29 Mar 2000 02:33:00 -0000 [thread overview]
Message-ID: <87snxagkf9.fsf@PC486.Niemitalo.LAN> (raw)
In-Reply-To: <m38zz2lu8c.fsf@kei.cwru.edu>
Keisuke Nishida <kxn30@po.cwru.edu> writes:
> I think everything in Scheme should be organized in the way of Scheme,
> including the naming style.
Naming style -- do you mean the question marks, or something else?
> Does Guile have any macro like `save-excursion'?
Actually, Guile has `save-module-excursion' which takes a thunk
parameter. So I suppose `save-excursion' should take a thunk,
and the convenient macro (if we provide one) should be called
something else like `begin-save-excursion'.
> Maybe the new (emacs macro) should provide those convenient macros?
That would be convenient. :-)
Here is a mostly tested implementation. I did not commit this to
CVS because I suppose this shouldn't be in 0.3 yet.
;;; (emacs emacs)
(define (lisp-macro->procedure lisp-macro)
"Return a procedure which calls LISP-MACRO.
The returned procedure accepts one argument, THUNK. It calls
LISP-MACRO with one argument: a form which comes back to Scheme and
calls THUNK."
(lambda (thunk)
"Call some Lisp macro, passing it a form which calls THUNK."
(lisp-eval `(,lisp-macro (scheme-eval '(',thunk))))))
(define (lisp-macro-1->procedure lisp-macro)
"Return a procedure which calls LISP-MACRO.
The returned procedure accepts two arguments, PARAM and THUNK. It
calls LISP-MACRO with two arguments: the quoted PARAM, and a form
which comes back to Scheme and calls THUNK."
(lambda (param thunk)
"Call some Lisp macro, passing it PARAM and a form which calls THUNK."
(lisp-eval `(,lisp-macro ',param (scheme-eval '(',thunk))))))
;;; (emacs import)
(define-public save-excursion
(lisp-macro->procedure 'save-excursion))
(define-public with-current-buffer
(lisp-macro-1->procedure 'with-current-buffer))
;;; (emacs macro)
(define-macro (define-begin-macro macro-name procedure)
"Define a macro MACRO-NAME which calls PROCEDURE with a thunk.
The thunk evaluates the macro arguments when called.
MACRO-NAME is an unevaluated symbol. PROCEDURE is any expression
evaluating to a procedure, such as a variable. It is evaluated
where `define-begin-macro' is called."
`(define-macro ,macro-name
(let ((procedure-val ,procedure))
(lambda body
"Call some procedure with a thunk which evaluates BODY."
`(',procedure-val (lambda () ,@body))))))
(define-macro (define-begin-macro-1 macro-name procedure)
"Define a macro MACRO-NAME which calls PROCEDURE with a parameter and a thunk.
The thunk evaluates the other arguments when called.
MACRO-NAME is an unevaluated symbol. PROCEDURE is any expression
evaluating to a procedure, such as a variable. It is evaluated
where `define-begin-macro-1' is called."
`(define-macro ,macro-name
(let ((procedure-val ,procedure))
(lambda (param . body)
"Call some procedure with PARAM and a thunk which evaluates BODY."
`(',procedure-val ,param (lambda () ,@body))))))
(define-macro (define-public-begin-macro macro-name procedure)
"Like `define-begin-macro', but also export MACRO-NAME."
`(begin
(define-begin-macro ,macro-name ,procedure)
(export ,macro-name)))
(define-macro (define-public-begin-macro-1 macro-name procedure)
"Like `define-begin-macro-1', but also export MACRO-NAME."
`(begin
(define-begin-macro-1 ,macro-name ,procedure)
(export ,macro-name)))
(define-public-begin-macro begin-save-excursion save-excursion)
(define-public-begin-macro-1 begin-with-current-buffer with-current-buffer)
next prev parent reply other threads:[~2000-03-29 2:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-27 22:51 Keisuke Nishida
2000-03-28 4:01 ` Kalle Olavi Niemitalo
2000-03-28 10:27 ` Keisuke Nishida
2000-03-28 11:37 ` Ken Raeburn
2000-03-28 23:06 ` Kalle Olavi Niemitalo
2000-03-29 16:57 ` Keisuke Nishida
2000-03-28 11:43 ` Kalle Olavi Niemitalo
2000-03-28 12:23 ` Keisuke Nishida
2000-03-29 2:33 ` Kalle Olavi Niemitalo [this message]
2000-03-29 17:09 ` Keisuke Nishida
2000-04-30 12:08 ` Kalle Olavi Niemitalo
2000-03-31 17:48 ` Keisuke Nishida
2000-03-31 22:42 ` Klaus Schilling
2000-04-01 9:02 ` Keisuke Nishida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87snxagkf9.fsf@PC486.Niemitalo.LAN \
--to=tosi@stekt.oulu.fi \
--cc=guile-emacs@sourceware.cygnus.com \
--cc=kxn30@po.cwru.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).