summaryrefslogtreecommitdiff
path: root/elisp/geiser-repl.el
diff options
context:
space:
mode:
authorMichael W <gcr@sneakygcr.net>2012-08-12 15:12:56 -0600
committerMichael W <gcr@sneakygcr.net>2012-08-12 15:12:56 -0600
commit5a799cacc8a87d94c5110f019d28fc7f43c7ad97 (patch)
tree026a14e52021012fc0a2e4d2290c980b5c7b8a91 /elisp/geiser-repl.el
parentc08d3d8fd11c8713f0d418431b5c8595667879a0 (diff)
downloadgeiser-5a799cacc8a87d94c5110f019d28fc7f43c7ad97.tar.gz
geiser-5a799cacc8a87d94c5110f019d28fc7f43c7ad97.tar.bz2
[WIP] Emacs cleans up temp. images, and a parameter controls whether or not they are displayed in the REPL.
Diffstat (limited to 'elisp/geiser-repl.el')
-rw-r--r--elisp/geiser-repl.el29
1 files changed, 25 insertions, 4 deletions
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 05d4775..05bb584 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -113,6 +113,11 @@ If you have a slow system, try to increase this time."
:type 'integer
:group 'geiser-repl)
+(geiser-custom--defcustom geiser-repl-inline-images t
+ "Whether to display inline images in the REPL"
+ :type 'boolean
+ :group 'geiser-repl)
+
(geiser-custom--defface repl-input
'comint-highlight-input geiser-repl "evaluated input highlighting")
@@ -272,13 +277,29 @@ module command as a string")
(save-excursion
(goto-char (point-min))
(while (re-search-forward "#<Image: \\([-+./_0-9a-zA-Z]+\\)>" nil t)
- (let ((file (match-string 1)))
- (replace-match "")
- (insert-image (create-image file) "[image]"))))))
+ ;; can't pass a filename to create-image because emacs might
+ ;; not display it before it gets deleted (race condition)
+ (let* ((file (match-string 1))
+ (begin (match-beginning 0))
+ (end (match-end 0))
+ (imgdata (save-excursion
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (insert-file-contents-literally file nil)
+ (buffer-string)))))
+ (delete-region begin end)
+ (put-image (create-image imgdata nil t) begin "[image]")
+ (delete-file file)
+ ; XXX need to ensure that the file is in the temporary
+ ; folder before deleting it. Racket will only generate files
+ ; in the system temporary folder (/var/tmp), but we don't
+ ; know what the temp. folder is, especially on Windows
+ )))))
(defun geiser-repl--output-filter (txt)
(geiser-con--connection-update-debugging geiser-repl--connection txt)
- (geiser-repl--replace-images)
+ (when (and geiser-repl-inline-images (display-images-p))
+ (geiser-repl--replace-images))
(when (string-match-p (geiser-con--connection-prompt geiser-repl--connection)
txt)
(geiser-autodoc--disinhibit-autodoc)))