From: Óscar Fuentes Date: Mon, 23 Jun 2014 23:45:50 +0000 (+0200) Subject: Increases/decreases wpm on the fly X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=9f3a3bd2793955083a394d2e527209bc273e0d57;p=spray Increases/decreases wpm on the fly Adds keybindings `f' and `s' for faster/slower wpm rate. --- diff --git a/Readme.org b/Readme.org index 5e379c1..9f30145 100644 --- a/Readme.org +++ b/Readme.org @@ -35,6 +35,12 @@ In spray-mode buffers, following commands are available. - =spray-forward-word= (l, ) :: inverse of =spray-backward-word= +- =spray-faster= (f) :: + increases speed + +- =spray-slower= (s) :: + decreases speed + Press any key else to quit =spray-mode=. ** Customization diff --git a/spray.el b/spray.el index aab9f8e..48819cb 100644 --- a/spray.el +++ b/spray.el @@ -54,6 +54,8 @@ (define-key km (kbd "l") 'spray-forward-word) (define-key km (kbd "") 'spray-backward-word) (define-key km (kbd "") 'spray-forward-word) + (define-key km (kbd "f") 'spray-faster) + (define-key km (kbd "s") 'spray-slower) km) "keymap for spray-mode buffers") @@ -198,6 +200,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)