branch: elpa/gnosis
commit e1f8e479cca6d8161a8e95528a5b0f0c1999c03f
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>

    monkeytype: Add optional arg for highlighting mistakes.
---
 gnosis-monkeytype.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/gnosis-monkeytype.el b/gnosis-monkeytype.el
index 0dea124840c..93d8c3d87bb 100644
--- a/gnosis-monkeytype.el
+++ b/gnosis-monkeytype.el
@@ -29,6 +29,9 @@
 
 ;;; Code:
 
+(require 'gnosis-utils)
+
+
 (defface gnosis-monketype-face-dimmed
   '((((class color) (background light)) :foreground "grey50")
     (((class color) (background  dark)) :foreground "grey50"))
@@ -108,16 +111,21 @@
     (message "WPM: %.2f (Time: %.2f seconds)" wpm elapsed-seconds)
     wpm))
 
-(defun gnosis-monkeytype (text thema-type)
-  "Monkeytype TEXT for selected THEMA-TYPE."
+(defun gnosis-monkeytype (text thema-type &optional mistakes)
+  "Monkeytype TEXT for selected THEMA-TYPE.
+
+Optionally, highlight MISTAKES."
   (when (and gnosis-monkeytype-enable (member thema-type 
gnosis-monkeytype-themata))
     (with-current-buffer (get-buffer-create gnosis-monkeytype-buffer-name)
       (erase-buffer)
-      (let ((text-formatted (gnosis-monkeytype--format-text text))
+      (let ((text-formatted (gnosis-utils-highlight-words
+                            text mistakes 'gnosis-monkeytype-face-wrong
+                            'gnosis-monketype-face-dimmed))
            (start-time (current-time)))
        (setq gnosis-monkeytype-string text-formatted)
        (gnosis-monkeytype-mode)
        (insert text-formatted)
+       (fill-paragraph)
        (switch-to-buffer (get-buffer-create gnosis-monkeytype-buffer-name))
        (goto-char (point-min))
        (add-hook 'after-change-functions #'gnosis-monkeytype--handle-change)

Reply via email to