* wesnoth-mode.el (wesnoth-kill-block): Add support for prefix arg and
authorChris Mann <chpln@internode.on.net>
Thu, 12 Mar 2009 11:59:25 +0000 (12 22:29 +1030)
committerChris Mann <chpln@internode.on.net>
Thu, 12 Mar 2009 11:59:25 +0000 (12 22:29 +1030)
  improve.
  (wesnoth-forward-list, wesnoth-backward-list): Tidied.
  (wesnoth-mode-version): Updated to 1.3.5+git.

wesnoth-mode.el

index cfd0627..8d2fe05 100644 (file)
@@ -33,6 +33,9 @@
 ;; to automatically load wesnoth-mode for all files ending in '.cfg'.
 
 ;;; History:
+;; 1.3.5+git
+;; * Add support for prefix arg to and improved `wesnoth-kill-block' to kill
+;;   multiple blocks.
 ;; 1.3.5
 ;; * Added navigation commands: C-M-n and C-M-p can be used to move to the
 ;;   next and previous children of the current parent element, respectively.
 (require 'wesnoth-update)
 (require 'wesnoth-wml-data)
 
-(defconst wesnoth-mode-version "1.3.5"
+(defconst wesnoth-mode-version "1.3.5+git"
   "The current version of `wesnoth-mode'.")
 
 (defgroup wesnoth-mode nil "Wesnoth-mode access"
@@ -1388,19 +1391,22 @@ the end of the region to place the overlay."
                                            (goto-char start)
                                            (point-marker)))))
 
-(defun wesnoth-kill-block ()
-  "Kill the block at point."
-  (interactive)
+(defun wesnoth-kill-block (arg)
+  "Kill ARG blocks at point."
+  (interactive "p")
   (save-excursion
-    (let ((kill-whole-line t))
-      (if (looking-at "[\t ]*\\(\\[\\+?\\(\\w\\|_\\)+\\]\\|#define\\|\
+    (while (> arg 0)
+      (let ((kill-whole-line t))
+        (while (and (looking-at "[\t ]*$") (= (forward-line 1) 0)))
+        (if (looking-at "[\t ]*\\(\\[\\+?\\(\\w\\|_\\)+\\]\\|#define\\|\
 #ifn?def\\)")
-          (kill-region (point)
-                       (save-excursion
-                         (wesnoth-jump-to-matching)
-                         (forward-line 1)
-                         (point)))
-        (kill-line))
+            (kill-region (point)
+                         (save-excursion
+                           (wesnoth-jump-to-matching)
+                           (forward-line 1)
+                           (point)))
+          (kill-line))
+        (setq arg (1- arg)))
       (wesnoth-indent))))
 
 (defun wesnoth-mark-block ()
@@ -1460,12 +1466,13 @@ If ARG is not specified, move backward up one level."
       (when (numberp parent)
         (back-to-indentation)))))
 
-(defun wesnoth-forward-list (&optional arg)
+(defun wesnoth-forward-list (arg)
   "Move to forward ARG elements at the current depth.
 If ARG is not specifed, move forward one element."
   (interactive "p")
-  (unless arg
-    (setq arg 1))
+  (while (and (save-excursion (beginning-of-line)
+                              (looking-at "[\t ]*$"))
+              (= (forward-line 1) 0)))
   (when (save-excursion (beginning-of-line)
                       (looking-at (wesnoth-element-opening)))
     (wesnoth-jump-to-matching)
@@ -1488,12 +1495,12 @@ If ARG is not specifed, move forward one element."
     (wesnoth-jump-to-matching))
   (end-of-line))
 
-(defun wesnoth-backward-list (&optional arg)
+(defun wesnoth-backward-list (arg)
   "Move to backward ARG elements at the current depth.
 If ARG is not specifed, move backward one element."
   (interactive "p")
-  (unless arg
-    (setq arg 1))
+  (while (and (save-excursion (beginning-of-line) (looking-at "[\t ]*$"))
+              (= (forward-line -1) 0)))
   (when (save-excursion (beginning-of-line)
                         (looking-at (wesnoth-element-closing)))
     (wesnoth-jump-to-matching)