Merge remote-tracking branch 'oscarfv/faster-slower'
[spray] / spray.el
index aab9f8e1988a0e9ada1e137e70f5542ef6a97106..77df087f748797441aa1651bdfebbe9a08ad1f08 100644 (file)
--- a/spray.el
+++ b/spray.el
@@ -54,6 +54,8 @@
     (define-key km (kbd "l") 'spray-forward-word)
     (define-key km (kbd "<left>") 'spray-backward-word)
     (define-key km (kbd "<right>") 'spray-forward-word)
+    (define-key km (kbd "f") 'spray-faster)
+    (define-key km (kbd "s") 'spray-slower)
     km)
   "keymap for spray-mode buffers")
 
 (make-face 'spray-base-face)
 (set-face-attribute 'spray-base-face nil
                     :background (face-background 'default)
-                    :foreground (face-foreground 'default))
+                    :foreground (face-foreground 'default)
+                    :slant 'normal)
 
 (make-face 'spray-orp-face)
 (set-face-attribute 'spray-orp-face nil
                     :foreground "red"
                     :overline (face-foreground 'default)
-                    :underline (face-foreground 'default))
+                    :underline (face-foreground 'default)
+                    :slant 'normal)
 
 ;; * internal vars
 
@@ -198,6 +202,32 @@ an integer or a float value."
   (skip-chars-backward "\s\t\n")
   (spray--word-at-point))
 
+(defun spray-faster ()
+  "Increases speed.
+
+Increases the wpm (words per minute) parameter. See the variable
+`spray-wmp'."
+  (interactive)
+  (spray-inc-wpm 20))
+
+(defun spray-slower ()
+  "Decreases speed.
+
+Decreases the wpm (words per minute) parameter. See the variable
+`spray-wmp'."
+  (interactive)
+  (spray-inc-wpm -20))
+
+(defun spray-inc-wpm (delta)
+  (let ((was-running spray--running))
+    (spray-start/stop -1)
+    (when (< 10 (+ spray-wpm delta))
+      (setq spray-wpm (+ spray-wpm delta)))
+    (spray-backward-word)
+    (message "spray wpm: %d" spray-wpm)
+    (when was-running
+      (spray-start/stop 1))))
+
 ;; * provide
 
 (provide 'spray)