diff options
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-image.el | 38 | ||||
-rw-r--r-- | elisp/geiser-racket.el | 10 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 3 |
3 files changed, 29 insertions, 22 deletions
diff --git a/elisp/geiser-image.el b/elisp/geiser-image.el index 1d8a03a..3e2a666 100644 --- a/elisp/geiser-image.el +++ b/elisp/geiser-image.el @@ -1,6 +1,6 @@ ;; geiser-image.el -- support for image display -;; Copyright (c) 2012 Jose Antonio Ortega Ruiz +;; Copyright (c) 2012, 2015 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 @@ -14,6 +14,7 @@ (require 'geiser-custom) (require 'geiser-base) +(require 'geiser-impl) ;;; Customization: @@ -34,34 +35,35 @@ :group 'geiser-image) (geiser-custom--defcustom geiser-image-cache-dir nil - ;; Currently, this variable is updated, if needed, by racket during - ;; initialization. If/when we add image support for other - ;; implementations, we'll have to work with implementation-specific - ;; caches. - "Directory where generated images are stored. If nil, the -system wide tmp dir will be used." + "Default directory where generated images are stored. + +If nil,the 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") +(geiser-impl--define-caller geiser-image--cache-dir image-cache-dir () + "Directory where generated images are stored. If this function +returns nil, no images are generated.") + (defun geiser-image--list-cache () "List all the images in the image cache." - (and geiser-image-cache-dir - (file-directory-p geiser-image-cache-dir) - (let ((files (directory-files-and-attributes - geiser-image-cache-dir t "geiser-img-[0-9]*.png"))) - (mapcar 'car - (sort files (lambda (a b) - (< (float-time (nth 6 a)) - (float-time (nth 6 b))))))))) + (let ((cdir (geiser-image--cache-dir nil))) + (and cdir + (file-directory-p cdir) + (let ((files (directory-files-and-attributes cdir t + "geiser-img-[0-9]*.png"))) + (mapcar 'car (sort files (lambda (a b) + (< (float-time (nth 6 a)) + (float-time (nth 6 b)))))))))) (defun geiser-image--clean-cache () "Clean all except for the last `geiser-image-cache-keep-last' -images in `geiser-image-cache-dir'." +images in `geiser-image--cache-dir'." (interactive) (dolist (f (butlast (geiser-image--list-cache) geiser-image-cache-keep-last)) (delete-file f))) @@ -101,9 +103,7 @@ images in `geiser-image-cache-dir'." (if (and inline-images-p (display-images-p)) (insert-image (create-image file) "[image]") (geiser-image--insert-button file) - (when auto-p (geiser-image--display file))) - (setq geiser-image-cache-dir (file-name-directory file)) - (geiser-image--clean-cache))))) + (when auto-p (geiser-image--display file))))))) seen)) (defun geiser-view-last-image (n) diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el index 8a0d46d..6a849e3 100644 --- a/elisp/geiser-racket.el +++ b/elisp/geiser-racket.el @@ -1,6 +1,6 @@ ;; geiser-racket.el -- geiser support for Racket scheme -;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 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 @@ -366,6 +366,8 @@ using start-geiser, a procedure in the geiser/server module." (defun geiser-racket--version (binary) (shell-command-to-string (format "%s -e '(display (version))'" binary))) +(defvar geiser-racket--image-cache-dir nil) + (defun geiser-racket--startup (remote) (set (make-local-variable 'compilation-error-regexp-alist) `(("^ *\\([^:(\t\n]+\\):\\([0-9]+\\):\\([0-9]+\\):" 1 2 3))) @@ -373,9 +375,12 @@ using start-geiser, a procedure in the geiser/server module." (if geiser-image-cache-dir (geiser-eval--send/wait `(:eval (image-cache ,geiser-image-cache-dir) geiser/user)) - (setq geiser-image-cache-dir + (setq geiser-racket--image-cache-dir (geiser-eval--send/result '(:eval (image-cache) geiser/user))))) +(defun geiser-racket--image-cache-dir () + (or geiser-image-cache-dir geiser-racket--image-cache-dir)) + ;;; Additional commands @@ -434,6 +439,7 @@ Use a prefix to be asked for a submodule name." (external-help geiser-racket--external-help) (check-buffer geiser-racket--guess) (keywords geiser-racket--keywords) + (image-cache-dir geiser-racket--image-cache-dir) (case-sensitive geiser-racket-case-sensitive-p) (binding-forms geiser-racket--binding-forms) (binding-forms* geiser-racket--binding-forms*)) diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 9ecbd25..c5c0490 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -1,6 +1,6 @@ ;;; geiser-repl.el --- Geiser's REPL -;; Copyright (C) 2009, 2010, 2011, 2012, 2013 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015 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 @@ -440,6 +440,7 @@ module command as a string") (setq geiser-eval--default-connection-function 'geiser-repl--connection) (defun geiser-repl--prepare-send () + (geiser-image--clean-cache) (geiser-autodoc--inhibit-autodoc) (geiser-con--connection-deactivate geiser-repl--connection)) |