emacs-devel
[Top][All Lists]
Advanced

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

Re: SVG gauges in Emacs


From: Ted Zlatanov
Subject: Re: SVG gauges in Emacs
Date: Mon, 01 Feb 2010 12:18:16 -0600
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.90 (gnu/linux)

On Mon, 18 Jan 2010 20:38:58 +0100 address@hidden wrote: 

j> I have some different elisp SVG hacks. Maybe the attached "dragbox.el"
j> can be of help. It allows one to draw a box in an image interactively,
j> so its somewhat like drawing a gauge.

Thanks so much, Joakim.  I was able to put together colorful message
count indicators for Gnus.  The display speed is not bad at all, I can
show 20-50 200x30 SVG-generated icons in less than a second.

I'm still tinkering with the exact display: the message counts range
from 0 to 1000+ and I want to show visually that one group has more
messages than another.  So this is not ready yet but when it is, I'll
post about it to the ding (Gnus development) newsgroup.  I don't think
it's very interesting to all of emacs-devel.

I did come up with one useful function, though:

(defun tzz-image-from-svg-string (svg-data)
  (with-temp-buffer
    (let* ((image (create-image svg-data 'svg t :ascent 'center))
           (props `(display ,image intangible ,image)))
      (insert "i")
      (add-text-properties (point-min) (point-max) props)
      (buffer-string))))

The :ascent property is very important to make the icon look good in the
middle of a text stream.  As long as the image is not taller than the
text, the row doesn't get the extra line padding it would otherwise.

It's also important to propertize a single character so it can be
deleted in one DEL stroke.  auto-image-file-mode for example creates a
long string that takes a few keystrokes to actually kill.

Thanks
Ted





reply via email to

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