Long ago (in 2006!), I blogged on an annoying misfeature of Emacs when editing HTML files: you can't type double dashes. Emacs sees them as an SGML comment and insists on indenting all subsequent lines in strange ways.
I wrote about finding a fix for the problem, involving commenting out four lines in sgml-mode.el. That file had a comment at the very beginning suggesting that they know about the problem and had guarded against it, but obviously it didn't work and the variable that was supposed to control the behavior had been overridden by other hardwired behaviors.
That fix has worked well for eight years. But just lately, I've been getting a lot of annoying warnings when I edit HTML files: "Error: autoloading failed to define function sgml_lexical_context". Apparently the ancient copy of sgml-mode.el that I'd been using all these years was no longer compatible with ... something else somewhere inside emacs. I needed to update it.
Maybe, some time during the intervening 8 years, they'd actually fixed the problem? I was hopeful. I moved my old patched sgml-mode.el aside and edited some files. But the first time I tried typing a double dashes -- like this, with text inside that's long enough to wrap to a new line -- I saw that the problem wasn't fixed at all.
I got a copy of the latest sgml-mode.el -- on Debian, that meant:
apt-get install emacs23-el cp /usr/share/emacs/23.4/lisp/textmodes/sgml-mode.el.gz ~/.emacs-lisp gunzip ~/.emacs-lisp/sgml-mode.el.gzThen I edited the file and started searching for strings like font-lock and comment.
Unfortunately, the solution I documented in my old blog post is no longer helpful. The code has changed too much, and now there are many, many different places where automatic comment handling happens. I had to comment out each of them bit by bit before I finally found the section that's now causing the problem. Commenting out these lines fixed it:
(set (make-local-variable 'indent-line-function) 'sgml-indent-line) (set (make-local-variable 'comment-start) "") (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent) (set (make-local-variable 'comment-line-break-function) 'sgml-comment-indent-new-line)
I didn't have to remove any .elc files, like I did in 2006; just putting the sgml-mode.el file in my Emacs load-path was enough. I keep all my customized Emacs code in a directory called .emacs-lisp, and in my .emacs I make sure it's in my path:
(setq load-path (cons "~/.emacs-lisp/" load-path))And now I can type double dashes again. Whew!
[ 12:42 Apr 29, 2014 More linux/editors | permalink to this entry | comments ]