public inbox for
 help / color / mirror / Atom feed
From: Kalle Olavi Niemitalo <>
Subject: scheme-find-definition
Date: Tue, 09 May 2000 03:23:00 -0000	[thread overview]
Message-ID: <87aei0yt1a.fsf@PC486.Niemitalo.local> (raw)

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?

(import-lisp-function find-file)
(import-lisp-function goto-line)
(import-lisp-function move-to-column)

(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)))))
		    ((procedure? 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)))

             reply	other threads:[~2000-05-09  3:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-09  3:23 Kalle Olavi Niemitalo [this message]
2000-05-09  4:03 ` scheme-find-definition Keisuke Nishida
2000-05-09 22:16   ` scheme-find-definition Kalle Olavi Niemitalo
2000-05-09 23:46     ` scheme-find-definition 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aei0yt1a.fsf@PC486.Niemitalo.local \ \ \

* 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).