# HG changeset patch
# User Daniel Pfeiffer <occitan@esperanto.org>
# Date 1098826737 0
# Node ID e60d53125cf26fb75bf1f05c84a248c1b34908e2
# Parent  d198f03d3ba53eef2dea0995eb47384e5b483dad
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.

diff -r d198f03d3ba5 -r e60d53125cf2 lisp/textmodes/sgml-mode.el
--- a/lisp/textmodes/sgml-mode.el	Tue Oct 26 21:38:09 2004 +0000
+++ b/lisp/textmodes/sgml-mode.el	Tue Oct 26 21:38:57 2004 +0000
@@ -453,10 +453,22 @@
   ;; recognized.
   (set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*")
   (set (make-local-variable 'comment-end-skip) "[ \t]*--\\([ \t\n]*>\\)?")
-  ;; This definition probably is not useful in derived modes.
-  (set (make-local-variable 'imenu-generic-expression)
-       (concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\("
-	       sgml-name-re "\\)")))
+  ;; This definition has an HTML leaning but probably fits well for other modes.
+  (setq imenu-generic-expression
+	`((nil
+	   ,(concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\("
+		    sgml-name-re "\\)")
+	   2)
+	  ("Id"
+	   ,(concat "<[^>]+[ \t\n]+[Ii][Dd]=\\(['\"]"
+		    (if sgml-xml-mode "" "?")
+		    "\\)\\(" sgml-name-re "\\)\\1")
+	   2)
+	  ("Name"
+	   ,(concat "<[^>]+[ \t\n]+[Nn][Aa][Mm][Ee]=\\(['\"]"
+		    (if sgml-xml-mode "" "?")
+		    "\\)\\(" sgml-name-re "\\)\\1")
+	   2))))
 
 ;; Some programs (such as Glade 2) generate XML which has
 ;; -*- mode: xml -*-.