From 4b52cd8fbedae9af7c4e123f4ff0eb7b29e4bfe1 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Sat, 6 Sep 2008 18:30:41 +0930 Subject: [PATCH] * wesnoth-mode.el: Clean-up several long lines. (wesnoth-within-define, wesnoth-find-macro-definitions): Use point-markers instead of line-numbers. (wesnoth-indent-region): Minor indentation correction. --- wesnoth-mode.el | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/wesnoth-mode.el b/wesnoth-mode.el index 6570b72..0c50e26 100644 --- a/wesnoth-mode.el +++ b/wesnoth-mode.el @@ -36,7 +36,7 @@ ;; * Point is now placed at the first non-whitespace character of the line, ;; instead of the last. ;; * Corrected minor indentation bugs. -;; * Indenting a large region is now much more efficient. +;; * Indenting across large regions is now much more efficient. ;; 1.2.3 ;; * Now compatible with GNU Emacs 21.4. ;; * Added support for several new tags. @@ -45,8 +45,8 @@ ;; * Indentation can now be customised using `wesnoth-indent-preprocessor-bol' ;; and `wesnoth-indent-savefile'; support for `wesnoth-indentation-function' ;; has been removed. -;; * Trailing whitespace is no longer created when creating a second consecutive -;; newline. +;; * Trailing whitespace is no longer created when creating a second +;; consecutive newline. ;; * Spurious newlines are no longer created when inserting a tag elements ;; around a region. ;; 1.2.2 @@ -79,8 +79,8 @@ ;; now checks preprocessor statements for correct nesting. ;; * `wesnoth-newline' and `wesnoth-newline-and-indent' can now be forced to ;; perform indentation by providing a prefix argument. -;; * Indentation styles 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. ;; * `outline-minor-mode' now works on macro definitions. @@ -201,7 +201,8 @@ indent the line." '("#\\(?:define\\|\\(?:ifn?\\|un\\)def\\)" . 'wesnoth-preprocessor-face) '("\\(#\\(?:define\\|\\(?:ifn?\\|un\\)def\\)\\)[\t ]+\\(\\(\\w\\|_\\)+\\)" 2 font-lock-function-name-face) - '("\\(#e\\(?:lse\\|nd\\(?:\\(?:de\\|i\\)f\\)\\)\\)" . 'wesnoth-preprocessor-face) + '("\\(#e\\(?:lse\\|nd\\(?:\\(?:de\\|i\\)f\\)\\)\\)" . + 'wesnoth-preprocessor-face) '("\\({[@~]?\\(\\w\\|\\.\\|/\\|-\\)+}\\)" (1 font-lock-function-name-face)) '("\\({\\(\\w\\|:\\|_\\)+\\|{[~@]?\\)" @@ -514,13 +515,13 @@ Otherwise return nil." (defun wesnoth-within-define (position) "Determine whether point is currently inside a #define block. POSITION is the initial cursor position." - (let ((depth 0) - (def-info (or wesnoth-define-blocks (wesnoth-find-macro-definitions)))) - (dolist (element def-info) - (when (= (cadr (sort (append (car (cdr element)) - (list (line-number-at-pos position))) - '>)) - (line-number-at-pos position)) + (let ((depth 0)) + (dolist (element (or wesnoth-define-blocks + (wesnoth-find-macro-definitions))) + (when (= (cadr (sort (append (mapcar 'marker-position (cadr element)) + (list position)) + '>)) + position) (setq depth (max (car element) depth)))) depth)) @@ -535,10 +536,10 @@ POSITION is the initial cursor position." (setq depth (if (string= (match-string 1) "#define") (progn - (add-to-list 'openings (line-number-at-pos (point))) + (add-to-list 'openings (point-marker)) (1+ depth)) (add-to-list 'cache - (list depth (list (car openings) (line-number-at-pos (point))))) + (list depth (list (car openings) (point-marker)))) (setq openings (cdr openings)) (1- depth))) (end-of-line)) @@ -560,7 +561,7 @@ Creates and destroys a cache of macro definition details as necessary." (forward-line 1) (if (looking-at "^[\t ]*$") (indent-line-to 0) - (funcall indent-line-function)))) + (funcall indent-line-function)))) (setq wesnoth-define-blocks nil))) (defun wesnoth-determine-context (position) -- 2.11.4.GIT