Klimi's new dotfiles with stow.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

46 líneas
1.5 KiB

hace 5 años
  1. (eval-and-compile
  2. (require 'slime))
  3. (define-slime-contrib slime-media
  4. "Display things other than text in SLIME buffers"
  5. (:authors "Christophe Rhodes <csr21@cantab.net>")
  6. (:license "GPL")
  7. (:slime-dependencies slime-repl)
  8. (:swank-dependencies swank-media)
  9. (:on-load
  10. (add-hook 'slime-event-hooks 'slime-dispatch-media-event)))
  11. (defun slime-media-decode-image (image)
  12. (mapcar (lambda (image)
  13. (if (plist-get image :data)
  14. (plist-put image :data (base64-decode-string (plist-get image :data)))
  15. image))
  16. image))
  17. (defun slime-dispatch-media-event (event)
  18. (slime-dcase event
  19. ((:write-image image string)
  20. (let ((img (or (find-image (slime-media-decode-image image))
  21. (create-image image))))
  22. (slime-media-insert-image img string))
  23. t)
  24. ((:popup-buffer bufname string mode)
  25. (slime-with-popup-buffer (bufname :connection t :package t)
  26. (when mode (funcall mode))
  27. (princ string)
  28. (goto-char (point-min)))
  29. t)
  30. (t nil)))
  31. (defun slime-media-insert-image (image string &optional bol)
  32. (with-current-buffer (slime-output-buffer)
  33. (let ((marker (slime-repl-output-target-marker :repl-result)))
  34. (goto-char marker)
  35. (slime-propertize-region `(face slime-repl-result-face
  36. rear-nonsticky (face))
  37. (insert-image image string))
  38. ;; Move the input-start marker after the REPL result.
  39. (set-marker marker (point)))
  40. (slime-repl-show-maximum-output)))
  41. (provide 'slime-media)