;;; guile-emacs.scm --- Guile Emacs interface
-;; Copyright (C) 2001 Keisuke Nishida <kxn30@po.cwru.edu>
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Copyright (C) 2001, 2010 Keisuke Nishida <kxn30@po.cwru.edu>
+
+;;;; This library is free software; you can redistribute it and/or
+;;;; modify it under the terms of the GNU Lesser General Public
+;;;; License as published by the Free Software Foundation; either
+;;;; version 3 of the License, or (at your option) any later version.
+;;;;
+;;;; This library is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;;; Lesser General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free
+;;;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+;;;; 02111-1307 USA
;;; Code:
\f
;;;
-;;; for guile-import and guile-use-modules
+;;; for guile-import and guile-import-module
;;;
-(define (guile-emacs-export-procedure proc)
- (define (procedure-arity proc)
- (assq-ref (procedure-properties proc) 'arity))
-
+(define (guile-emacs-export-procedure name proc docs)
(define (procedure-args proc)
(let ((source (procedure-source proc)))
(if source
((symbol? formals) `(&rest ,formals))
(else (cons (car formals) (loop (cdr formals))))))
;; arity -> emacs args
- (let* ((arity (procedure-arity proc))
+ (let* ((arity (procedure-minimum-arity proc))
(nreqs (car arity))
(nopts (cadr arity))
(restp (caddr arity)))
(define (procedure-call name args)
(let ((restp (memq '&rest args))
- (args (map (lambda (a) `(let ((_t ,a))
- (if (guile-tokenp _t)
- (cadr _t)
- (list 'quote _t))))
- (delq '&rest (delq '&optional args)))))
+ (args (delq '&rest (delq '&optional args))))
(if restp
- `(list 'apply ',name ,@args)
- `(list ',name ,@args))))
+ `('apply ',name ,@args)
+ `(',name ,@args))))
- (let ((name (procedure-name proc))
- (args (procedure-args proc))
- (docs (object-documentation proc)))
+ (let ((args (procedure-args proc))
+ (docs (and docs (object-documentation proc))))
`(defun ,name ,args
,@(if docs (list docs) '())
- (guile-lisp-eval ,(procedure-call name args)))))
+ (guile-lisp-flat-eval ,@(procedure-call (procedure-name proc) args)))))
-(define (guile-emacs-export proc-name)
- (guile-emacs-export-procedure (module-ref (current-module) proc-name)))
+(define (guile-emacs-export proc-name func-name docs)
+ (let ((proc (module-ref (current-module) proc-name)))
+ (guile-emacs-export-procedure func-name proc docs)))
-(define (guile-emacs-export-procedures module-name)
+(define (guile-emacs-export-procedures module-name docs)
(define (module-public-procedures name)
(hash-fold (lambda (s v d)
(let ((val (variable-ref v)))
- (if (procedure? val) (cons val d) d)))
+ (if (procedure? val) (acons s val d) d)))
'() (module-obarray (resolve-interface name))))
- `(progn ,@(map guile-emacs-export-procedure
+ `(progn ,@(map (lambda (n+p)
+ (guile-emacs-export-procedure (car n+p) (cdr n+p) docs))
(module-public-procedures module-name))))
\f
;;;
-;;; for guile-emacs-complete-symbol
+;;; for guile-scheme-complete-symbol
;;;
(define (guile-emacs-complete-alist str)
apropos-fold-all)
(lambda (p1 p2) (string<? (car p1) (car p2)))))
+\f
+;;;
+;;; for guile-scheme-apropos
+;;;
+
+(define (guile-emacs-apropos regexp)
+ (with-output-to-string (lambda () (apropos regexp))))
+
+\f
+;;;
+;;; for guile-scheme-describe
+;;;
+
+(define (guile-emacs-describe sym)
+ (object-documentation (eval sym (current-module))))
+
+\f
+;;;
+;;; Guile 1.4 compatibility
+;;;
+
+(define object->string
+ (if (defined? 'object->string)
+ object->string
+ (lambda (x) (format #f "~S" x))))
+
;;; guile-emacs.scm ends here