diff options
Diffstat (limited to 'elisp/geiser-guile.el')
-rw-r--r-- | elisp/geiser-guile.el | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index 9855a11..b76228e 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -100,6 +100,47 @@ 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 () + (with--geiser-implementation 'guile + (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) + (if (eq key 'geiser-debugger) + (comint-send-string nil "bt\n") + (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 () @@ -157,7 +198,7 @@ This function uses `geiser-guile-init-file' if it exists." (find-module geiser-guile--get-module) (enter-command geiser-guile--enter-command) (find-symbol-begin geiser-guile--symbol-begin) - (display-error) + (display-error geiser-guile--display-error) (display-help) (check-buffer geiser-guile--guess)) |