diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-06-19 16:52:03 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-06-19 16:52:03 +0200 |
commit | 841766449b9dc14d40186a67cdceda26fc6ca4ff (patch) | |
tree | 075fcb90e84eafb0946e5804a5b6b7c38a07194c | |
parent | d2e8efd5b449bddaad5b416cb3634532a235576d (diff) | |
download | geiser-chez-841766449b9dc14d40186a67cdceda26fc6ca4ff.tar.gz geiser-chez-841766449b9dc14d40186a67cdceda26fc6ca4ff.tar.bz2 |
Guile: backtrace buttonization.
-rw-r--r-- | elisp/geiser-guile.el | 38 | ||||
-rw-r--r-- | scheme/guile/geiser/emacs.scm | 3 | ||||
-rw-r--r-- | scheme/guile/geiser/xref.scm | 9 |
3 files changed, 48 insertions, 2 deletions
diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index 44a4e9f..ed2a555 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -121,6 +121,44 @@ This function uses `geiser-guile-init-file' if it exists." (save-excursion (skip-syntax-backward "^-()>") (point)))) +;;; Error display +(defvar geiser-guile--file-cache (make-hash-table :test 'equal)) + +(defun geiser-guile--resolve-file (file) + (when (and (stringp file) (not (string-equal file "unknown file"))) + (if (file-name-absolute-p file) file + (or (gethash file geiser-guile--file-cache) + (puthash file + (geiser-eval--send/result `(:eval ((:ge find-file) ,file))) + geiser-guile--file-cache))))) + +(defconst geiser-guile--file-rx + "^In \\([^\n:]+\\):\n *\\([[:digit:]]+\\|\\?\\):") + +(defun geiser-guile--find-files () + (save-excursion + (while (re-search-forward geiser-guile--file-rx nil t) + (let ((file (match-string 1)) + (beg (match-beginning 1)) + (end (match-end 1)) + (line (string-to-number (or (match-string 2) "0")))) + (let ((file (geiser-guile--resolve-file file))) + (when file + (geiser-edit--make-link beg end file line 0))))))) + +(defun geiser-guile-display-error (module key msg) + (when key + (insert "Error: ") + (geiser--insert-with-face (format "%s" key) 'bold) + (newline 2)) + (when msg + (let ((p (point))) + (insert msg) + (goto-char p) + (geiser-guile--find-files))) + t) + + ;;; Trying to ascertain whether a buffer is Guile Scheme: (defun geiser-guile-guess () diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm index edae487..2aa91da 100644 --- a/scheme/guile/geiser/emacs.scm +++ b/scheme/guile/geiser/emacs.scm @@ -39,7 +39,8 @@ ge:module-exports ge:module-location ge:callers - ge:callees) + ge:callees + ge:find-file) #:use-module (geiser evaluation) #:use-module ((geiser modules) :renamer (symbol-prefix-proc 'ge:)) #:use-module ((geiser completion) :renamer (symbol-prefix-proc 'ge:)) diff --git a/scheme/guile/geiser/xref.scm b/scheme/guile/geiser/xref.scm index f00f724..2336fb2 100644 --- a/scheme/guile/geiser/xref.scm +++ b/scheme/guile/geiser/xref.scm @@ -28,7 +28,8 @@ #:export (symbol-location generic-methods callers - callees) + callees + find-file) #:use-module (geiser utils) #:use-module (geiser modules) #:use-module (geiser doc) @@ -90,4 +91,10 @@ (and obj (map procedure-xref (procedure-callees obj))))) +(define (find-file path) + (let loop ((dirs %load-path)) + (if (null? dirs) #f + (let ((candidate (string-append (car dirs) "/" path))) + (if (file-exists? candidate) candidate (loop (cdr dirs))))))) + ;;; xref.scm ends here |