From 9c66bb23477c52f0387507b8748711733485016d Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Fri, 25 Jan 2008 17:24:31 +1030 Subject: [PATCH] * wesnoth-mode.el: Fixed bug in preprocessor-bol indentation. Should now works with emacs 21. --- wesnoth-mode.el | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/wesnoth-mode.el b/wesnoth-mode.el index 0e21f3f..b531b4a 100644 --- a/wesnoth-mode.el +++ b/wesnoth-mode.el @@ -273,13 +273,21 @@ insert opening and closing tags around the specified region." (open-line 1)) (insert "[" tagname "]") (goto-char end) - (or (looking-back "^[\t ]*$") - (newline)) + (beginning-of-line) + (or (looking-at "^[\t ]*$") + (progn + (end-of-line) + (newline))) + (end-of-line) (insert "[/" tagname "]\n") (setq end (point)) ;; New target for indent-region (indent-region start end)) - (or (looking-back "^[\t ]*$") - (newline)) + (beginning-of-line) + (or (looking-at "^[\t ]*$") + (progn + (end-of-line) + (newline))) + (end-of-line) (wesnoth-insert-and-indent "[" tagname "]") (wesnoth-insert-and-indent "\n") (save-excursion @@ -446,7 +454,7 @@ Otherwise return nil." (beginning-of-line) (if (or (not (wesnoth-wml-start-pos)) (<= (point) (wesnoth-wml-start-pos)) - (nth 3 (syntax-ppss (point))) + (nth 3 (parse-partial-sexp (point-min) (point))) (and wesnoth-indent-preprocessor-bol (looking-at (concat "^[\t ]*" wesnoth-preprocessor-regexp)))) (indent-line-to 0) @@ -502,9 +510,9 @@ performed." (let ((upper) (lower)) (save-excursion - (end-of-line) - (when (looking-back "^[\t ]*#enddef") - (beginning-of-line)) + (beginning-of-line) + (unless (looking-at "^[\t ]*#enddef") + (end-of-line)) (search-backward-regexp "^[\t ]*\\(#define\\|#enddef\\)" (wesnoth-wml-start-pos) t) (if (looking-at "^[\t ]*#define") @@ -524,15 +532,15 @@ performed." (if (and (not (wesnoth-within-define)) wesnoth-indent-preprocessor-bol) (progn (search-backward-regexp - (wesnoth-element t) + (wesnoth-element) (wesnoth-wml-start-pos) t) (while (and (wesnoth-within-define) (not (= (point) (wesnoth-wml-start-pos)))) (search-backward-regexp - (wesnoth-element t) + (wesnoth-element) (wesnoth-wml-start-pos) 0))) (search-backward-regexp - (wesnoth-element t) + (wesnoth-element) (wesnoth-wml-start-pos) 0))) ;;; WML checks -- 2.11.4.GIT