geiser-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Geiser-users] Image support for Guile


From: Mark Witmer
Subject: Re: [Geiser-users] Image support for Guile
Date: Sun, 13 Jan 2013 09:39:54 -0500

Of course after sleeping on it, I realized that writing a Guile module that stores image files and outputs #<Image: filename> like Racket does would let you use a nicer image format, not kill Emacs's poor regex engine on larger images, and wouldn't require the patch. Still, it was a fun little hack!

Mark


On Sat, Jan 12, 2013 at 8:47 PM, Mark Witmer <address@hidden> wrote:

I've been using Geiser for a few months now and I love it!

I was wondering why we have to let Racket have all the fun with
displaying inline images, so I wrote a little Guile package to store and
output XPM images.

 Then you could make a change like the following to get
geiser-image--replace-images in geiser-image.el to recognize and replace
the /* XPM */ sections:

diff -c /home/mark/.emacs.d/elpa/geiser-0.2.2/geiser-image.el /home/mark/development/geiser_image/geiser-image.el
*** /home/mark/.emacs.d/elpa/geiser-0.2.2/geiser-image.el       2013-01-12 20:28:35.814782222 -0500
--- /home/mark/development/geiser_image/geiser-image.el 2013-01-12 20:27:59.395073875 -0500
***************
*** 90,110 ****
      (with-silent-modifications
        (save-excursion
          (goto-char (point-min))
!         (while (re-search-forward "\"?#<Image: \\([-+./_0-9a-zA-Z]+\\)>\"?" nil t)
!           (setq seen (+ 1 seen))
!           (let* ((file (match-string 1))
!                  (begin (match-beginning 0))
!                  (end (match-end 0)))
!             (delete-region begin end)
!             (goto-char begin)
!             (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)))))
      seen))

  (defun geiser-view-last-image (n)
    "Open the last displayed image in the system's image viewer.

--- 90,121 ----
      (with-silent-modifications
        (save-excursion
          (goto-char (point-min))
!       (let ((search-and-replace
!              (lambda (search-string inline-xpm-p)
!                (while (re-search-forward search-string nil t)
!                  (setq seen (+ 1 seen))
!                  (let* ((file (match-string 1))
!                         (begin (match-beginning 0))
!                         (end (match-end 0)))
!                    (delete-region begin end)
!                    (goto-char begin)
!                    (if (and inline-images-p (display-images-p))
!                        (insert-image
!                         (if inline-xpm-p
!                             (create-image file 'xpm t)
!                             (create-image file)) "[image]")
!                      (when (not inline-xpm-p)
!                        (progn
!                          (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))))))
!         (funcall search-and-replace "\"?#<Image: \\(/\\* XPM \\*/.*;\\)>\"?" t)
!         (funcall search-and-replace "\"?#<Image: \\([-+./_0-9a-zA-Z]+\\)>\"?" nil))))
      seen))

+ (defun geiser-image--replace-image (inline-images-p auto-p image begin end))
+
  (defun geiser-view-last-image (n)
    "Open the last displayed image in the system's image viewer.

Hope that's of interest to someone!

Mark Witmer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]