From 58f4cb8e7d394005a0757d863ad3de9339abf531 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 25 Jan 2016 10:54:02 -0500 Subject: [PATCH] * lisp/textmodes/sgml-mode.el (sgml-forward-sexp): New function (sgml-cursor-sensor, sgml-pretty-print, sgml-parse-tag-backward) (sgml-calculate-indent): Use it. --- lisp/textmodes/sgml-mode.el | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index f729760e9ca..e6eb060d8a4 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -842,6 +842,25 @@ Return non-nil if we skipped over matched tags." (setq arg (1- arg))) return)) +(defun sgml-forward-sexp (n) + ;; This function is needed in major-modes such as nxml-mode where + ;; forward-sexp-function is used to give a more dwimish behavior to + ;; the `forward-sexp' command. + ;; Without it, we can end up with backtraces like: + ;; "get-text-property" (0xffffc0f0) + ;; "nxml-token-after" (0xffffc2ac) + ;; "nxml-forward-single-balanced-item" (0xffffc46c) + ;; "nxml-forward-balanced-item" (0xffffc61c) + ;; "forward-sexp" (0xffffc7f8) + ;; "sgml-parse-tag-backward" (0xffffc9c8) + ;; "sgml-lexical-context" (0xffffcba8) + ;; "sgml-mode-flyspell-verify" (0xffffcd74) + ;; "flyspell-word" (0xffffcf3c) + ;; "flyspell-post-command-hook" (0xffffd108) + ;; FIXME: should we also set the sgml-tag-syntax-table? + (let ((forward-sexp-function nil)) + (forward-sexp n))) + (defvar sgml-electric-tag-pair-overlays nil) (defvar sgml-electric-tag-pair-timer nil) @@ -1067,9 +1086,9 @@ With prefix argument ARG, repeat this ARG times." ((and (eq (char-before) ?>) (or (not (eq (char-after) ?<)) (> x y))) - (backward-sexp)) + (sgml-forward-sexp -1)) ((eq (char-after y) ?<) - (forward-sexp))) + (sgml-forward-sexp 1))) (point)))) (message "Invisible tag: %s" ;; Strip properties, otherwise, the text is invisible. @@ -1236,7 +1255,7 @@ You might want to turn on `auto-fill-mode' to get better results." (unless (or ;;(looking-at " isn't really the end of a tag. Skip it. (goto-char (1- tag-end)) @@ -1541,7 +1560,7 @@ LCON is the lexical context, if any." (`text (while (looking-at "