From: zk_phi Date: Thu, 12 Jun 2014 15:54:16 +0000 (+0900) Subject: hide '.'-terminated words slightly faster X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=e2beca4dfeff3f26ea1c8960c3c39a7b9ba9b1c7;p=spray hide '.'-terminated words slightly faster --- diff --git a/spray.el b/spray.el index a34b58f..7d42d01 100644 --- a/spray.el +++ b/spray.el @@ -1,5 +1,5 @@ ;; custom -(defvar spray-freq (/ 60.0 300) "60.0 / WPM") +(defvar spray-freq (/ 60.0 400) "60.0 / WPM") (defvar spray-text-scale 5) (defvar spray-orp-face 'error) @@ -58,29 +58,33 @@ (defun turn-off-spray-mode () (interactive) (spray-mode -1)) (defun spray-next () - (if (not (zerop spray--delay)) - (setq spray--delay (1- spray--delay)) - (widen) - (if (eobp) - (turn-off-spray-mode) - (skip-chars-forward "\s\t\n") - (let* ((beg (point)) - (len (skip-chars-forward "^\s\t\n")) - (end (point)) - (orp (+ beg (cl-case len - ((1) 1) - ((2 3 4 5) 2) - ((6 7 8 9) 3) - ((10 11 12 13) 4) - (t 5))))) - (setq spray--delay (+ (if (> len 8) 1 0) (cl-case (char-before) - ((?. ?! ?\? ?\;) 3) - ((?, ?:) 1) - (t 0)))) - (overlay-put spray--padding-overlay - 'before-string (make-string (- 5 (- orp beg)) ?\s)) - (move-overlay spray--padding-overlay beg (1+ beg)) - (move-overlay spray--orp-overlay (1- orp) orp) - (narrow-to-region beg end))))) + (cond ((not (zerop spray--delay)) + (setq spray--delay (1- spray--delay)) + (when (and (<= spray--delay 2) + (= (char-before) ?.)) + (narrow-to-region (point) (point)))) + (t + (widen) + (if (eobp) + (turn-off-spray-mode) + (skip-chars-forward "\s\t\n") + (let* ((beg (point)) + (len (skip-chars-forward "^\s\t\n")) + (end (point)) + (orp (+ beg (cl-case len + ((1) 1) + ((2 3 4 5) 2) + ((6 7 8 9) 3) + ((10 11 12 13) 4) + (t 5))))) + (setq spray--delay (+ (if (> len 8) 1 0) (cl-case (char-before) + ((?. ?! ?\? ?\;) 3) + ((?, ?:) 1) + (t 0)))) + (overlay-put spray--padding-overlay + 'before-string (make-string (- 5 (- orp beg)) ?\s)) + (move-overlay spray--padding-overlay beg (1+ beg)) + (move-overlay spray--orp-overlay (1- orp) orp) + (narrow-to-region beg end)))))) (provide 'spray)