X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b00453052c5e7ca3a5c84ce2d0cb37b863754b70..d3857d85ab7e18b5dafdb6395e811bb566f8184b:/lisp/textmodes/sgml-mode.el diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 87c9e820e1..584056bf30 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -111,8 +111,6 @@ This takes effect when first loading the `sgml-mode' library.") (define-key map "\"" 'sgml-name-self)) (when (memq ?' sgml-specials) (define-key map "'" 'sgml-name-self))) - (define-key map (vector (make-char 'latin-iso8859-1)) - 'sgml-maybe-name-self) (let ((c 127) (map (nth 1 map))) (while (< (setq c (1+ c)) 256) @@ -208,7 +206,7 @@ This takes effect when first loading the `sgml-mode' library.") (let ((table (make-char-table 'sgml-table)) (i 32) elt) - (while (< i 256) + (while (< i 128) (setq elt (aref sgml-char-names i)) (if elt (aset table (make-char 'latin-iso8859-1 i) elt)) (setq i (1+ i))) @@ -368,8 +366,8 @@ Otherwise, it is set to be buffer-local when the file has (looking-at "\\s-*<\\?xml") (when (re-search-forward (eval-when-compile - (mapconcat 'identity - '("" limit 'move) + (or (re-search-backward "[<>]" limit 'move) (error "No tag found")) + (when (eq (char-after) ?<) + ;; Oops!! Looks like we were not in a textual context after all!. + ;; Let's try to recover. + (with-syntax-table sgml-tag-syntax-table + (forward-sexp) + (forward-char -1))) (setq tag-end (1+ (point))) (cond ((sgml-looking-back-at "--") ; comment @@ -1082,15 +1087,17 @@ Leave point at the beginning of the tag." (goto-char tag-start) (sgml-make-tag tag-type tag-start tag-end name))) -(defun sgml-get-context (&optional full) +(defun sgml-get-context (&optional until) "Determine the context of the current position. -If FULL is `empty', return even if the context is empty (i.e. +By default, parse until we find a start-tag as the first thing on a line. +If UNTIL is `empty', return even if the context is empty (i.e. we just skipped over some element and got to a beginning of line). -If FULL is non-nil, parse back to the beginning of the buffer, otherwise -parse until we find a start-tag as the first thing on a line. The context is a list of tag-info structures. The last one is the tag -immediately enclosing the current position." +immediately enclosing the current position. + +Point is assumed to be outside of any tag. If we discover that it's +not the case, the first tag returned is the one inside which we are." (let ((here (point)) (ignore nil) (context nil) @@ -1101,12 +1108,13 @@ immediately enclosing the current position." ;; enclosing start-tags we'll have to ignore. (skip-chars-backward " \t\n") ; Make sure we're not at indentation. (while - (and (or ignore - (not (if full (eq full 'empty) context)) + (and (not (eq until 'now)) + (or ignore + (not (if until (eq until 'empty) context)) (not (sgml-at-indentation-p)) (and context (/= (point) (sgml-tag-start (car context))) - (sgml-unclosed-tag-p (sgml-tag-name (car context))))) + (sgml-unclosed-tag-p (sgml-tag-name (car context))))) (setq tag-info (ignore-errors (sgml-parse-tag-backward)))) ;; This tag may enclose things we thought were tags. If so, @@ -1117,6 +1125,10 @@ immediately enclosing the current position." (setq context (cdr context))) (cond + ((> (sgml-tag-end tag-info) here) + ;; Oops!! Looks like we were not outside of any tag, after all. + (push tag-info context) + (setq until 'now)) ;; start-tag ((eq (sgml-tag-type tag-info) 'open) @@ -1207,99 +1219,113 @@ the current start-tag or the current comment or the current cdata, ..." (and (not sgml-xml-mode) (member-ignore-case tag-name sgml-unclosed-tags))) -(defun sgml-calculate-indent () - "Calculate the column to which this line should be indented." - (let ((lcon (sgml-lexical-context))) - - ;; Indent comment-start markers inside