summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-11-30 02:02:01 +0000
committerjao <jao@gnu.org>2021-11-30 02:02:01 +0000
commit2d6f41685be7591137a47f22937969cc2b607c9a (patch)
treeebe5b3de680c633e22f4abd1823b59ff2051dfad /elisp
parent61507dd264bec743cdc5843162ebc8779cf6d896 (diff)
downloadgeiser-2d6f41685be7591137a47f22937969cc2b607c9a.tar.gz
geiser-2d6f41685be7591137a47f22937969cc2b607c9a.tar.bz2
Better handling of REPL's output regions
FSVO better, but at least the code is cleaner and prompts regexps more accurate.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-connection.el8
-rw-r--r--elisp/geiser-repl.el52
2 files changed, 27 insertions, 33 deletions
diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el
index 9b98373..1068330 100644
--- a/elisp/geiser-connection.el
+++ b/elisp/geiser-connection.el
@@ -1,6 +1,6 @@
;;; geiser-connection.el -- talking to a scheme process
-;; Copyright (C) 2009, 2010, 2011, 2013 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010, 2011, 2013, 2021 Jose Antonio Ortega Ruiz
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the Modified BSD License. You should
@@ -92,11 +92,11 @@
(tq-queue-pop tq)))))))
(defun geiser-con--combined-prompt (prompt debug)
- (format "\\(%s%s\\)" prompt (if debug (format "\\|%s" debug) "")))
+ (if debug (format "\\(%s\\)\\|\\(%s\\)" prompt debug) prompt))
(defun geiser-con--connection-eot-re (prompt debug)
- (geiser-con--combined-prompt (format "\n%s" prompt)
- (and debug (format "\n%s" debug))))
+ (geiser-con--combined-prompt (format "\n\\(%s\\)" prompt)
+ (and debug (format "\n\\(%s\\)" debug))))
(defun geiser-con--make-connection (proc prompt debug-prompt)
(list t
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 6f28ae8..814c501 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -464,37 +464,31 @@ module command as a string")
(let ((font-lock-dont-widen t))
(font-lock-default-unfontify-region (point-min) (point-max))))))
-(defun geiser-repl--output-filter (txt)
- (let ((mark-output nil))
+(defun geiser-repl--find-output-region ()
+ (save-excursion
+ (goto-char (point-max))
+ (re-search-backward comint-prompt-regexp)
+ (move-to-column 0)
+ (set-marker geiser-repl--last-output-end (point))
(save-excursion
- (goto-char (point-max))
- (re-search-backward comint-prompt-regexp)
- ;; move to start of line to prevent accidentally marking a REPL prompt
- (move-to-column 0)
- ;; Only mark output which:
- ;; a) is not on the REPL output line
- ;; b) has at least one character
- ;;
- ;; This makes the magic number for distance 3 -- as the newline
- ;; after executing expression is also counted. This is due to the point
- ;; being set before comint-send-input.
- ;;
- ;; Restriction a) applies due to our inability to distinguish between
- ;; output from the REPL, and the REPL prompt output.
- (let ((distance (- (point) geiser-repl--last-output-start)))
- (when (> distance 2)
- (setq mark-output t)
- (set-marker geiser-repl--last-output-end (point)))))
- (when mark-output
- (with-silent-modifications
- (add-text-properties (1+ geiser-repl--last-output-start)
- geiser-repl--last-output-end
- `(read-only ,geiser-repl-read-only-output-p))
- (geiser-repl--fontify-output-region geiser-repl--last-output-start
- geiser-repl--last-output-end)
- (geiser--font-lock-ensure geiser-repl--last-output-start
- geiser-repl--last-output-end))))
+ (when (re-search-backward comint-prompt-regexp nil t)
+ (forward-line)
+ (when (> (point) geiser-repl--last-output-start)
+ (set-marker geiser-repl--last-output-start (point)))))
+ (> (- geiser-repl--last-output-end geiser-repl--last-output-start) 2)))
+
+(defun geiser-repl--treat-output-region ()
+ (with-silent-modifications
+ (add-text-properties (1- geiser-repl--last-output-start)
+ geiser-repl--last-output-end
+ `(read-only ,geiser-repl-read-only-output-p))
+ (geiser-repl--fontify-output-region geiser-repl--last-output-start
+ geiser-repl--last-output-end)
+ (geiser--font-lock-ensure geiser-repl--last-output-start
+ geiser-repl--last-output-end)))
+(defun geiser-repl--output-filter (txt)
+ (when (geiser-repl--find-output-region) (geiser-repl--treat-output-region))
(geiser-con--connection-update-debugging geiser-repl--connection txt)
(geiser-image--replace-images geiser-repl-inline-images-p
geiser-repl-auto-display-images-p)