[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Indentation bug in html-mode
From: |
Stefan Monnier |
Subject: |
Re: Indentation bug in html-mode |
Date: |
Wed, 25 Apr 2007 14:49:07 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux) |
>>>>> "Lennart" == Lennart Borgman (gmail) <address@hidden> writes:
> Stefan Monnier wrote:
>>> The attached file is valid XHTML 1.1 but indents badly because of the < inte
>>> <?php ... ?> part. I paste it here for simplicity too:
>>
>> Hmm... does the patch below fix it for you?
>> If you put a "<?" inside your PHP code, it seems it would still be valid
>> XML, but indentation will probably get confused.
> It fixes the last two lines (</body> and </html>), but not the </div> line.
The additional patch below should fix that, provided Emacs is in XHTML mode
(rather than HTML mode). If I understand the HTML docs properly your
example code is not valid in HTML because the < is not allowed inside
<?php ...>.
Stefan
--- orig/lisp/textmodes/sgml-mode.el
+++ mod/lisp/textmodes/sgml-mode.el
@@ -1033,6 +1033,13 @@
(let ((cdata-start (point)))
(unless (search-forward "]]>" pos 'move)
(list 0 nil nil 'cdata nil nil nil nil cdata-start))))
+ ((and sgml-xml-mode (looking-at "<\\?"))
+ ;; Processing Instructions.
+ ;; In SGML, it's basically a normal tag of the form
+ ;; <?NAME ...> but in XML, it takes the form <? ... ?>.
+ (let ((pi-start (point)))
+ (unless (search-forward "?>" pos 'move)
+ (list 0 nil nil 'pi nil nil nil nil pi-start))))
(t
;; We've reached a tag. Parse it.
;; FIXME: Handle net-enabling start-tags