changeset 72129:b5439b7a1ef1

(tumme-backward-image): Add prefix argument. Add error when at first image. (tumme-forward-image): Add prefix argument. Add error when at last image.
author Mathias Dahl <mathias.dahl@gmail.com>
date Wed, 26 Jul 2006 09:55:10 +0000
parents 21666477f16c
children c7889d24e9d7
files lisp/tumme.el
diffstat 1 files changed, 38 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/tumme.el	Wed Jul 26 09:55:00 2006 +0000
+++ b/lisp/tumme.el	Wed Jul 26 09:55:10 2006 +0000
@@ -1072,32 +1072,46 @@
   (if tumme-track-movement
       (tumme-track-thumbnail)))
 
-(defun tumme-forward-image ()
-  "Move to next image and display properties."
-  (interactive)
-  ;; Before we move, make sure that there is an image two positions
-  ;; forward.
-  (when (save-excursion
-        (forward-char 2)
-        (tumme-image-at-point-p))
-    (forward-char)
-    (while (and (not (eobp))
-                (not (tumme-image-at-point-p)))
-      (forward-char))
-    (if tumme-track-movement
-        (tumme-track-original-file)))
+(defun tumme-forward-image (&optional arg)
+  "Move to next image and display properties.
+Optional prefix ARG says how many images to move; default is one
+image."
+  (interactive "p")
+  (let (pos (steps (or arg 1)))
+    (dotimes (i steps)
+      (if (and (not (eobp))
+               (save-excursion
+                 (forward-char)
+                 (while (and (not (eobp))
+                             (not (tumme-image-at-point-p)))
+                   (forward-char))
+                 (setq pos (point))
+                 (tumme-image-at-point-p)))
+          (goto-char pos)
+        (error "At last image"))))
+  (when tumme-track-movement
+    (tumme-track-original-file))
   (tumme-display-thumb-properties))
 
-(defun tumme-backward-image ()
-  "Move to previous image and display properties."
-  (interactive)
-  (when (not (bobp))
-    (backward-char)
-    (while (and (not (bobp))
-                (not (tumme-image-at-point-p)))
-      (backward-char))
-    (if tumme-track-movement
-        (tumme-track-original-file)))
+(defun tumme-backward-image (&optional arg)
+  "Move to previous image and display properties.
+Optional prefix ARG says how many images to move; default is one
+image."
+  (interactive "p")
+  (let (pos (steps (or arg 1)))
+    (dotimes (i steps)
+      (if (and (not (bobp))
+               (save-excursion
+                 (backward-char)
+                 (while (and (not (bobp))
+                             (not (tumme-image-at-point-p)))
+                   (backward-char))
+                 (setq pos (point))
+                 (tumme-image-at-point-p)))
+          (goto-char pos)
+        (error "At first image"))))
+  (when tumme-track-movement
+    (tumme-track-original-file))
   (tumme-display-thumb-properties))
 
 (defun tumme-next-line ()