This is the mail archive of the
mailing list for the Guile project.
- To: guile-emacs at sourceware dot cygnus dot com
- Subject: scheme-find-definition
- From: Kalle Olavi Niemitalo <tosi at stekt dot oulu dot fi>
- Date: 09 May 2000 12:25:21 +0300
Here's a command which finds the source location of a Scheme
procedure, if the reader saved it. (read-enable 'positions)
I didn't commit this to CVS because Keisuke is rewriting the
Scheme files. Will that take long?
(define (find-filename-property tree)
"Return a part of TREE which has a `filename' source-property.
Return #f if not found."
(and (pair? tree)
(or (and (source-property tree 'filename) tree)
(find-filename-property (car tree))
(find-filename-property (cdr tree)))))
(define-command (scheme-find-procedure proc)
"Go to the definition of Scheme procedure PROC."
(interactive "SFind procedure: ")
;; Hack for converting interactively entered symbols to procedures.
;; This might go away, don't use this from programs.
(if (symbol? proc) (set! proc (eval proc)))
(let ((part (cond ((procedure-with-setter? proc)
(or (find-filename-property (procedure-source (procedure proc)))
(find-filename-property (procedure-source (setter proc)))))
(find-filename-property (procedure-source proc))))))
(or part (error "Can't find definition of " proc))
(find-file (source-property part 'filename))
(and=> (source-property part 'line)
(lambda (line) (goto-line (+ line 1))))
(and=> (source-property part 'column) move-to-column)))