From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: sgml-mode.el fixes for html-mode Date: Tue, 08 Mar 2005 02:35:48 +0200 Organization: JURTA Message-ID: <87mztenbrn.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1110251095 23238 80.91.229.2 (8 Mar 2005 03:04:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 8 Mar 2005 03:04:55 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 08 04:04:55 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D8V1R-0007QU-5t for ged-emacs-devel@m.gmane.org; Tue, 08 Mar 2005 04:04:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D8VEm-0007hp-Sm for ged-emacs-devel@m.gmane.org; Mon, 07 Mar 2005 22:18:24 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D8VED-0007ei-4A for emacs-devel@gnu.org; Mon, 07 Mar 2005 22:17:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D8VE2-0007XA-VN for emacs-devel@gnu.org; Mon, 07 Mar 2005 22:17:40 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D8VE1-0007WN-N9 for emacs-devel@gnu.org; Mon, 07 Mar 2005 22:17:37 -0500 Original-Received: from [194.126.101.98] (helo=MXR-4.estpak.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D8Uwx-0008S3-QI for emacs-devel@gnu.org; Mon, 07 Mar 2005 22:00:00 -0500 Original-Received: from mail.neti.ee (80-235-36-96-dsl.mus.estpak.ee [80.235.36.96]) by MXR-4.estpak.ee (Postfix) with ESMTP id D0A3C13145D for ; Tue, 8 Mar 2005 04:59:58 +0200 (EET) Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34304 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34304 I propose the following fixes for html-mode in sgml-mode.el. 1. With sgml-xml-mode=t HTML skeletons insert empty XHTML elements without a space before the trailing `/>'. But HTML compatibility guidelines recommend using such a space for compatibility with existing HTML user agents (i.e. `
' instead of `
'). 2. One bug fix for `C-c DEL' (`sgml-delete-tag') which on an empty XHTML element (e.g `
') deletes the subsequent unrelated tag too. This should check whether the tag ends with `/>'. 3. html-href-anchor skeleton asking for an URL has an initial input `http:'. This is inconvenient since `http://' is not the only one possible URL prefix. And even if it is more frequent, full URLs are rarely typed by hand, but more often copied from other places. 4. html-image could be consistent with html-href-anchor and ask for URL of an image and set the default point inside the `alt=""' HTML required attribute for the image description like html-href-anchor does for the link description between and . 5. XHTML standard recommends for compatibility with with existing HTML clients which don't support the use of ID-type attributes, to write the same ID and Name attributes, (e.g. ). 6. XML does not support attribute minimization. Attribute names such as `checked' cannot occur in elements without their value being specified. This means using `checked="checked"' instead of `checked'. 7. \n before

in the html-paragraph skeleton is a disservice rather than a convenience. Index: lisp/textmodes/sgml-mode.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/textmodes/sgml-mode.el,v retrieving revision 1.103 diff -u -r1.103 sgml-mode.el --- lisp/textmodes/sgml-mode.el 9 Feb 2005 15:50:36 -0000 1.103 +++ lisp/textmodes/sgml-mode.el 8 Mar 2005 00:21:42 -0000 @@ -629,7 +629,7 @@ (backward-char) '(("") " [ " _ " ]]")) ((and (eq v2 t) sgml-xml-mode (member ,str sgml-empty-tags)) - '(("") -1 "/>")) + '(("") -1 " />")) ((or (and (eq v2 t) (not sgml-xml-mode)) (string-match "^[/!?]" ,str)) nil) ((symbolp v2) @@ -818,7 +818,8 @@ (goto-char close) (kill-sexp 1)) (setq open (point)) - (when (sgml-skip-tag-forward 1) + (when (and (sgml-skip-tag-forward 1) + (not (looking-back "/>"))) (kill-sexp -1))) ;; Delete any resulting empty line. If we didn't kill-sexp, ;; this *should* do nothing, because we're right after the tag. @@ -1572,7 +1573,7 @@ ("dir" ,@list) ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7) ("form" (\n _ \n "" ">")) + (if sgml-xml-mode " />" ">")) ("action" ,@(cdr href)) ("method" ("get") ("post"))) ("h1" ,@align) ("h2" ,@align) @@ -1891,13 +1892,15 @@ (define-skeleton html-href-anchor "HTML anchor tag with href attribute." "URL: " - '(setq input "http:") + ;; '(setq input "http:") "" _ "") (define-skeleton html-name-anchor "HTML anchor tag with name attribute." "Name: " - "" _ "") + "" _ "") (define-skeleton html-headline-1 "HTML level 1 headline tags." @@ -1932,18 +1935,18 @@ (define-skeleton html-horizontal-rule "HTML horizontal rule tag." nil - (if sgml-xml-mode "


" "
") \n) + (if sgml-xml-mode "
" "
") \n) (define-skeleton html-image "HTML image tag." - nil - "" ">")) + "Image URL: " + "\""" ">")) (define-skeleton html-line "HTML line break tag." nil - (if sgml-xml-mode "
" "
") \n) + (if sgml-xml-mode "
" "
") \n) (define-skeleton html-ordered-list "HTML ordered list tags." @@ -1969,7 +1972,7 @@ "HTML paragraph tag." nil (if (bolp) nil ?\n) - \n "

" _ (if sgml-xml-mode "

")) + "

" _ (if sgml-xml-mode "

")) (define-skeleton html-checkboxes "Group of connected checkbox inputs." @@ -1981,12 +1984,13 @@ "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: "))) "\" value=\"" str ?\" (when (y-or-n-p "Set \"checked\" attribute? ") - (funcall skeleton-transformation " checked")) - (if sgml-xml-mode "/>" ">") + (funcall skeleton-transformation + (if sgml-xml-mode " checked=\"checked\"" " checked"))) + (if sgml-xml-mode " />" ">") (skeleton-read "Text: " (capitalize str)) (or v2 (setq v2 (if (y-or-n-p "Newline after text? ") (funcall skeleton-transformation - (if sgml-xml-mode "
" "
")) + (if sgml-xml-mode "
" "
")) ""))) \n)) @@ -2000,12 +2004,13 @@ "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: "))) "\" value=\"" str ?\" (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? "))) - (funcall skeleton-transformation " checked")) - (if sgml-xml-mode "/>" ">") + (funcall skeleton-transformation + (if sgml-xml-mode " checked=\"checked\"" " checked"))) + (if sgml-xml-mode " />" ">") (skeleton-read "Text: " (capitalize str)) (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ") (funcall skeleton-transformation - (if sgml-xml-mode "
" "
")) + (if sgml-xml-mode "
" "
")) ""))) \n)) -- Juri Linkov http://www.jurta.org/emacs/