small doc update
[spray] / spray.el
index 7e38b4eee3dbd13a0cad1a37dc6760cf1e7ddf5b..bb0ea2c0d68677286b7e59c38b8a6c173b47fbe4 100644 (file)
--- a/spray.el
+++ b/spray.el
@@ -1,4 +1,4 @@
-;;; cedit.el --- a speed reading mode
+;;; spray.el --- a speed reading mode
 
 ;; Copyright (C) 2014 zk_phi
 
@@ -19,7 +19,7 @@
 ;; Author: zk_phi
 ;; URL: http://hins11.yu-yake.com/
 ;; Author: Ian Kelling <ian@iankelling.org>
-;; Version: 0.0.1
+;; Version: 0.0.2
 
 ;;; Commentary:
 
@@ -38,6 +38,7 @@
 ;;; Change Log:
 ;; 0.0.0 test release
 ;; 0.0.1 add spray-set-margins
+;; 0.0.2 margin options, speed control, better quit
 
 ;;; Code:
 
@@ -47,6 +48,8 @@
 
 (defvar spray-wpm 400 "words/min")
 (defvar spray-height 400 "height of characters")
+(defvar spray-margin-top 1 "character margin at top of buffer. Characters are as big as spray text characters.")
+(defvar spray-margin-left 0 "character margin at left of buffer. Characters are as big as spray text characters.")
 
 (defvar spray-mode-map
   (let ((km (make-sparse-keymap)))
@@ -69,8 +72,8 @@
                     :foreground (face-foreground 'default)
                     :slant 'normal)
 
-(make-face 'spray-orp-face)
-(set-face-attribute 'spray-orp-face nil
+(make-face 'spray-accent-face)
+(set-face-attribute 'spray-accent-face nil
                     :foreground "red"
                     :overline (face-foreground 'default)
                     :underline (face-foreground 'default)
 
 ;; * utility functions
 
-(defun spray-set-margins (left above)
-  "Currently broken & not used:
-add margins before/above the spray text. each arguments can be
-an integer or a float value."
+(defun spray-set-margins ()
+  "Setup spray--margin-string"
   (setq spray--margin-string
-        (propertize " " 'display `((space-width ,left) (height ,(+ 1 above))))))
+        (concat (make-string spray-margin-top 10) ;; 10 = ascii newline
+                (make-string spray-margin-left 32)))) ;; 32 = ascii space
 
 ;; * the mode
 
@@ -119,8 +121,7 @@ an integer or a float value."
          (overlay-put spray--base-overlay 'priority 100)
          (overlay-put spray--base-overlay 'face 'spray-base-face)
          (overlay-put spray--orp-overlay 'priority 101)
-         (overlay-put spray--orp-overlay 'face 'spray-orp-face)
-         (add-hook 'pre-command-hook 'spray--pre-command-handler)
+         (overlay-put spray--orp-overlay 'face 'spray-accent-face)
          (spray-start))
         (t
          (setq cursor-type spray--saved-cursor-type)
@@ -134,7 +135,6 @@ an integer or a float value."
                (buffer-face-mode 1)))
          (delete-overlay spray--base-overlay)
          (delete-overlay spray--orp-overlay)
-         (remove-hook 'pre-command-hook 'spray--pre-command-handler)
          (spray-stop))))
 
 (defun spray-quit ()
@@ -142,10 +142,6 @@ an integer or a float value."
   (interactive)
   (spray-mode -1))
 
-(defun spray--pre-command-handler ()
-  (unless (string-match "^spray-" (symbol-name this-command))
-    (spray-mode -1)))
-
 (defun spray--word-at-point ()
   (skip-chars-backward "^\s\t\n")
   (let* ((beg (point))
@@ -165,6 +161,7 @@ an integer or a float value."
                             (t 0))))
     (move-overlay spray--orp-overlay (1- orp) orp)
     (move-overlay spray--base-overlay beg end)
+    (spray-set-margins)
     (overlay-put spray--base-overlay 'before-string
                  (concat spray--margin-string
                          (make-string (- 5 (- orp beg)) ?\s)))