[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SVG image type fixes
SVG image type fixes
Sat, 25 Aug 2007 17:16:36 +0300
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)
1. Currently visiting a non-SVG XML file fails with errors from the image
library and memory overflow. That's because the regexp in
`image-type-header-regexps' detecting the SVG image type of too lax and
recognizes non-SVG XML files as SVG. I fixed this regexp to be like
regexps that detect XML formats in `magic-fallback-mode-alist'.
This is still not ideal since it can't recognize some SVG types (e.g. when
DOCTYPE contains ENTITY definitions). Instead of trying to improve an
already overly complex regexp, it's better to use one function
`xmltok-forward-prolog' from the nXML package - another argument
to add this nice package to Emacs!
2. Since SVG is a text-based image format, it should be possible to
use XML mode to edit it. I fixed image-mode.el to associate the file
extension .svg with xml-mode and image-mode-maybe, exactly like this is
done for another text-based image format .xpm.
But like .xpm, now visiting .svg puts the file in text image mode that
shows the source of the image. This is bad even for .xpm and for any
text-based image format, because viewing image is more frequent action
than editing it. This is as inconvenient as if a Web browser displayed
the source HTML code initially, and only after typing a special key like
C-c C-c it rendered it as a HTML page.
Is it OK to change image-mode.el to display text-based image files
as an image initially instead as text?
3. Added support for the compressed .svgz format. These files get
decompressed by gzip with the help of jka-cmpr.
4. Currently it's difficult to see if Emacs recognized the image type
correctly when it can't display an image. Another need to know the image
type is when Emacs uses content-based recognition on a file without extension.
To make sure of this, I propose to add image type in square brackets to the
image-mode indicator on the mode line like:
5. The node `(elisp)Images' now should mention the image format `svg'.
But before adding it, I propose to split this large node (it's so large
that a menu in the end of this node is not visible after visiting this node),
and to move text starting with `The supported image formats include ...'
to a new node `Image formats'.