From: Tim Vaughan Date: Tue, 21 May 2019 11:30:08 +0000 (+0200) Subject: Add function for rendering sixel graphics in current buffer. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=9dba2f344047e702b78a0eb4f90f3dcdda7bfa01;p=sixel.git Add function for rendering sixel graphics in current buffer. --- diff --git a/sixel.el b/sixel.el index 775bb58..5448ab4 100644 --- a/sixel.el +++ b/sixel.el @@ -194,4 +194,18 @@ Returns a sixel image object." (sixel-image-to-xpm-pixels sixel-image) "};") (error "Incorrecly formatted sixel string")))) +(defun sixel-render-images-in-buffer () + "Find and render any sixel images in the current buffer." + (interactive) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "P[[:ascii:]]*\\\\" nil t) + (let ((sixel-string (match-string 0)) + (inhibit-read-only t)) + (delete-region (match-beginning 0) + (match-end 0)) + (insert-image + (create-image (sixel-to-xpm sixel-string) 'xpm t)) + (insert "\n"))))) + ;;; sixel.el ends here