From fb2465cf8b30733ef5d6281bc20c305ddf16cf9b Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Thu, 10 Jan 2008 16:31:09 +1030 Subject: [PATCH] * wesnoth-mode.el: Misc fixes, tidied comments and long lines. --- wesnoth-mode.el | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/wesnoth-mode.el b/wesnoth-mode.el index 81cdafd..9ddd681 100644 --- a/wesnoth-mode.el +++ b/wesnoth-mode.el @@ -33,11 +33,10 @@ ;;; Changes: ;; 1.2.2 ;; * Fixed a bug in savefile indentation where content was needed between -;; equivalent elements for indentation to work. +;; elements pairs for indentation to work. ;; * Fixed `wesnoth-newline-and-indent' ignoring the state of ;; `wesnoth-auto-indent-flag'. -;; * Fixed font-locking on #endif. -;; * Fixed `{...}' structures font-locking incorrectly. +;; * Fixed `{...}' structures and `#endif' not font-locking correctly. ;; * Added indentation styles: `wesnoth-indent-savefile-preproc', ;; `wesnoth-indent-default-preproc' which implement a a similar indentation ;; style to the existing styles, however all preprocessor statements are @@ -50,17 +49,20 @@ ;; `wesnoth-jump-backward', `wesnoth-jump-forward' to ;; `wesnoth-indent-default', `wesnoth-indent-savefile' and ;; `wesnoth-backward-tag', `wesnoth-forward-tag', respectively. -;; * Changed `wesnoth-newline' to behave more consistently. +;; * Modified `wesnoth-newline' to behave more consistently. +;; * `wesnoth-jump-to-matching', `wesnoth-forward-tag', `wesnoth-backward-tag' +;; now leave point at the beginning (when moving backward) or end (when moving +;; forward) of the match. ;; * `wesnoth-jump-to-matching' now attempts to find a target if necessary and ;; will now work on preprocessor statements. Will now warn if jump ;; destination may not be correct. ;; * Indentation style is now determined by `wesnoth-indentation-function'. ;; * `wesnoth-check-structure' can now be applied over an active region and ;; now checks preprocessor statements for correct nesting. -;; * `wesnoth-newline' and `wesnoth-newline-and-indent' can be forced to +;; * `wesnoth-newline' and `wesnoth-newline-and-indent' can now be forced to ;; perform indentation by providing a prefix argument. -;; * `wesnoth-indent-savefile' and `wesnoth-indent-default' now leave point at -;; the first non-whitespace character of the line. +;; * Indentation styles now leave point at the first non-whitespace character of +;; the line. ;; * `wesnoth-check-tag-names' now reports on success. ;; * `wesnoth-insert-tag' is now able to insert tags around a region. ;; 1.2.1 @@ -373,7 +375,9 @@ consistent for jumping to occur." (if (looking-at (wesnoth-element-opening)) (setq open-tags (1+ open-tags)) (when (looking-at (wesnoth-element-closing)) - (setq open-tags (1- open-tags)))))) + (setq open-tags (1- open-tags))))) + (end-of-line) + (search-backward-regexp "\\[\\|#")) (while (and (or (> open-tags 0) (not search-started)) (search-forward-regexp @@ -385,15 +389,18 @@ consistent for jumping to occur." (setq open-tags (1+ open-tags)) (when (looking-at (wesnoth-element-closing)) (setq open-tags (1- open-tags)))) - (end-of-line))) + (end-of-line)) + (end-of-line)) (setq tag-position (point))) - (and (wesnoth-check-structure (point) tag-position) - (message "%s" "Region concerning jump does not nest correctly; target may not be correct")) + (and search-backward + (end-of-line)) + (and (wesnoth-check-structure (min (point) tag-position) + (max (point) tag-position)) + (message "%s" "Region concerning jump does not nest correctly; \ +target may not be correct")) (if (interactive-p) (goto-char tag-position) - tag-position)) - (end-of-line) - (search-backward-regexp "\\[\\|#")) + tag-position))) ;;; Indentation @@ -426,7 +433,8 @@ surrounding tags." (if (or (not (wesnoth-wml-start-pos)) (<= (point) (wesnoth-wml-start-pos)) (nth 3 (syntax-ppss (point))) - (and preproc-bol (looking-at (concat "^[\t ]*" wesnoth-preprocessor-regexp))) + (and preproc-bol (looking-at + (concat "^[\t ]*" wesnoth-preprocessor-regexp))) (not (wesnoth-check-structure (wesnoth-wml-start-pos) (point)))) (indent-line-to 0) (let ((cur-indent)) @@ -446,7 +454,8 @@ surrounding tags." (wesnoth-element preproc-bol) (wesnoth-wml-start-pos) 0) ;; If opening preceded by opening, increase indentation (when (or (looking-at (wesnoth-element-opening preproc-bol)) - (not (wesnoth-check-structure (wesnoth-wml-start-pos) (point)))) + (not + (wesnoth-check-structure (wesnoth-wml-start-pos) (point)))) (setq cur-indent (+ (current-indentation) wesnoth-base-indent)))) ;; Not opening, not closing (t @@ -454,9 +463,11 @@ surrounding tags." ;; Decrease indent if preceded by closing (if savefile (and (looking-at (wesnoth-element-opening preproc-bol)) - (setq cur-indent (+ (current-indentation) wesnoth-base-indent))) + (setq cur-indent + (+ (current-indentation) wesnoth-base-indent))) (and (looking-at (wesnoth-element-closing preproc-bol)) - (setq cur-indent (- (current-indentation) wesnoth-base-indent)))))) + (setq cur-indent (- (current-indentation) + wesnoth-base-indent)))))) ;; Indentation change unnecessary (unless cur-indent (setq cur-indent (current-indentation)))) @@ -521,7 +532,7 @@ the location which an element was expected and the expected element will be displayed in the minibuffer." (interactive) (unless (or start end) - (if (and start end transient-mark-mode mark-active) + (if (and transient-mark-mode mark-active) (setq start (region-beginning) end (copy-marker (region-end))) (setq start (point-min) @@ -531,11 +542,8 @@ element will be displayed in the minibuffer." (expected nil)) (save-excursion (goto-char start) - (while (and - (search-forward-regexp - (wesnoth-element) - end t) - (not error-position)) + (while (and (search-forward-regexp (wesnoth-element) end t) + (not error-position)) (beginning-of-line) (if (looking-at "^[\t ]*#\\(\\w+\\)") (let ((preprocessor-name (match-string-no-properties 1))) -- 2.11.4.GIT