When opening a vector icon text file for editing, Emacs first tries to display it as an image. That is wrong ; If the file has errors, Emacs (25.3.2 - x86_64-pc-linux-gnu, GTK+ Version 3.18.9) crashes miserably. Well, I know it has errors, that why I opened it in a text editor in the first place :/
And furthermore, Emacs will hang even if the file doesn't have errors, but just because it cannot render it (like it's just several path
s with id
s inside a svg
grouping tag) which is frustrating to say the least.
How can I make Emacs load text files as text files and not try to render it (because it can't) unless I explicitly told him to?
PS - Yes, I know that I can switch to text-mode by pressing C-c C-c
.
What I tried
(add-to-list `auto-mode-alist
'("\\.svg\\'" . xml-mode))
But no, Emacs still crashes on me upon opening my icons.svg file because it tries to render it as an image (and it's actually several images) when actually it's not its job.
Annex: The SVG code
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="cross" viewBox="0 0 20 20">
<path d="M17.1 5.2l-2.6-2.6-4.6 4.7-4.7-4.7-2.5 2.6 4.7 4.7-4.7 4.7 2.5 2.5 4.7-4.7 4.6 4.7 2.6-2.5-4.7-4.7"/>
</symbol>
<symbol id="play" viewBox="0 0 15 15">
<path d="M690 60H40l330 570L700 60z" />
</symbol>
</svg>
M-x find-file-literaly
and thenM-x xml-mode
(add-to-list `auto-mode-alist '("\\.svg\\'" . xml-mode))
is sufficient to cause the svg file to be opened as xml (tested withemacs -Q
). Interestingly, on emacs-24, opening your svg file as an image (i.e. the default) does not cause a crash, while on emacs-26.0.90, it does.emacs -Q
session, but also, in this session my image displays, too!! Well, it's broken, but at least Emacs didn't crash. Curiouser and curiouser.