summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elisp/geiser-image.el32
-rw-r--r--elisp/geiser-repl.el21
2 files changed, 38 insertions, 15 deletions
diff --git a/elisp/geiser-image.el b/elisp/geiser-image.el
index 222e0d3..dd90f05 100644
--- a/elisp/geiser-image.el
+++ b/elisp/geiser-image.el
@@ -22,7 +22,6 @@
"Options for image displaying."
:group 'geiser)
-
(geiser-custom--defcustom geiser-system-image-viewer "display"
"Which system image viewer program to invoke upon M-x
`geiser-view-last-image'."
@@ -44,6 +43,9 @@ system wide tmp dir will be used."
:type 'path
:group 'geiser-image)
+(geiser-custom--defface image-button
+ 'button geiser-image "image buttons in terminal buffers")
+
(defun geiser-image--list-cache ()
@@ -64,7 +66,18 @@ images in `geiser-image-cache-dir'."
(dolist (f (butlast (geiser-image--list-cache) geiser-image-cache-keep-last))
(delete-file f)))
-(defun geiser-image--replace-images (inline-images-p)
+(defun geiser-image--display (file)
+ (start-process "Geiser image view" nil geiser-system-image-viewer file))
+
+(defun geiser-image--button-action (button)
+ (let ((file (button-get button 'geiser-image-file)))
+ (when (file-exists-p file) (geiser-image--display file))))
+
+(define-button-type 'geiser-image--button
+ 'action 'geiser-image--button-action
+ 'follow-link t)
+
+(defun geiser-image--replace-images (inline-images-p auto-p)
"Replace all image patterns with actual images"
(with-silent-modifications
(save-excursion
@@ -78,9 +91,13 @@ images in `geiser-image-cache-dir'."
(delete-region begin end)
(if (and inline-images-p (display-images-p))
(put-image (create-image file) begin "[image]")
- (progn
- (goto-char begin)
- (insert "[image] ; use M-x geiser-view-last-image to view")))
+ (goto-char begin)
+ (insert-text-button "[image]"
+ :type 'geiser-image--button
+ 'face 'geiser-font-lock-image-button
+ 'geiser-image-file file
+ 'help-echo "Click to display image")
+ (when auto-p (geiser-image--display file)))
(setq geiser-image-cache-dir (file-name-directory file))
(geiser-image--clean-cache))))))
@@ -92,10 +109,7 @@ image viewer."
(interactive "p")
(let ((images (reverse (geiser-image--list-cache))))
(if (>= (length images) n)
- (start-process "Geiser image view"
- nil
- geiser-system-image-viewer
- (nth (- n 1) images))
+ (geiser-image--display (nth (- n 1) images))
(error "There aren't %d recent images" n))))
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 7eb7cf0..ddcc6b8 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -46,8 +46,10 @@ REPL buffer."
:type 'boolean
:group 'geiser-repl)
-(geiser-custom--defcustom geiser-repl-history-filename (expand-file-name "~/.geiser_history")
+(geiser-custom--defcustom geiser-repl-history-filename
+ (expand-file-name "~/.geiser_history")
"File where REPL input history is saved, so that it persists between sessions.
+
This is actually the base name: the concrete Scheme
implementation name gets appended to it."
:type 'filename
@@ -114,10 +116,16 @@ 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--defcustom geiser-repl-inline-images-p t
+ "Whether to display inline images in the REPL."
+ :type 'boolean
+ :group 'geiser-repl)
+
+(geiser-custom--defcustom geiser-repl-auto-display-images-p t
+ "Whether to automatically invoke the external viewer to display
+images pooping up in the REPL."
+ :type 'boolean
+ :group 'geiser-repl)
(geiser-custom--defface repl-input
'comint-highlight-input geiser-repl "evaluated input highlighting")
@@ -274,7 +282,8 @@ module command as a string")
(defun geiser-repl--output-filter (txt)
(geiser-con--connection-update-debugging geiser-repl--connection txt)
- (geiser-image--replace-images geiser-repl-inline-images)
+ (geiser-image--replace-images geiser-repl-inline-images-p
+ geiser-repl-auto-display-images-p)
(when (string-match-p (geiser-con--connection-prompt geiser-repl--connection)
txt)
(geiser-autodoc--disinhibit-autodoc)))