From 65b34485983578803905b8a1349b897780c07425 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 1 Nov 2002 17:41:41 +0000 Subject: [PATCH] (sgml-skip-tag-backward, sgml-skip-tag-forward): Deal with xml-style empty tags. --- lisp/ChangeLog | 9 ++++-- lisp/textmodes/sgml-mode.el | 57 +++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d9a122381a0..cc09363392c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2002-11-01 Stefan Monnier + + * textmodes/sgml-mode.el (sgml-skip-tag-backward) + (sgml-skip-tag-forward): Deal with xml-style empty tags. + 2002-11-01 Kim F. Storm * info.el (Info-hide-note-references): New defcustom. @@ -9,8 +14,8 @@ --noediting option; added run-time check to exclude it. * info.el (Info-follow-reference, Info-next-reference) - (Info-prev-reference, Info-try-follow-nearest-node): Bind - inhibit-point-motion-hooks to t while parsing reference. + (Info-prev-reference, Info-try-follow-nearest-node): + Bind inhibit-point-motion-hooks to t while parsing reference. (Info-fontify-node): When font-lock-mode is enabled, display "*note" and "* menu" references in a more user friendly format. diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index dc2af7067f3..569f182367b 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -691,43 +691,46 @@ With prefix argument ARG, repeat this ARG times." (if (looking-at "]+\\)") ;; end tag, skip any nested pairs (let ((case-fold-search t) - (re (concat ". + "\\([^>]*[^/>]\\)?>"))) (while (and (re-search-backward re nil t) (eq (char-after (1+ (point))) ?/)) (forward-char 1) (sgml-skip-tag-backward 1)))) (setq arg (1- arg)))) -(defun sgml-skip-tag-forward (arg &optional return) +(defun sgml-skip-tag-forward (arg) "Skip to end of tag or matching closing tag if present. With prefix argument ARG, repeat this ARG times. Return t iff after a closing tag." (interactive "p") - (setq return t) - (while (>= arg 1) - (skip-chars-forward "^<>") - (if (eq (following-char) ?>) - (up-list -1)) - (if (looking-at "<\\([^/ \n\t>]+\\)") - ;; start tag, skip any nested same pairs _and_ closing tag - (let ((case-fold-search t) - (re (concat "= arg 1) + (skip-chars-forward "^<>") + (if (eq (following-char) ?>) + (up-list -1)) + (if (looking-at "<\\([^/ \n\t>]+\\)\\([^>]*[^/>]\\)?>") + ;; start tag, skip any nested same pairs _and_ closing tag + (let ((case-fold-search t) + (re (concat ". + "\\([^>]*[^/>]\\)?>")) + point close) + (forward-list 1) + (setq point (point)) + (while (and (re-search-forward re nil t) + (not (setq close + (eq (char-after (1+ (match-beginning 0))) ?/))) + (goto-char (match-beginning 0)) + (sgml-skip-tag-forward 1)) + (setq close nil)) + (unless close + (goto-char point) + (setq return nil))) + (forward-list 1)) + (setq arg (1- arg))) + return)) (defun sgml-delete-tag (arg) "Delete tag on or after cursor, and matching closing or opening tag. -- 2.39.2