From: Ian Kelling Date: Thu, 3 Jul 2014 21:36:16 +0000 (-0700) Subject: Handle em dash case of word—word like a comma X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=02d31260eed4067fbbff2d5a194171a0228bc791;p=spray Handle em dash case of word—word like a comma In this case "show an abrupt change in thought or be used where a full stop (period) is too strong and a comma too weak" http://en.wikipedia.org/wiki/Em_dash#Em_dash --- diff --git a/Readme.org b/Readme.org index 069f8e5..09b323a 100644 --- a/Readme.org +++ b/Readme.org @@ -103,9 +103,9 @@ In =./spray.el=, the functions =spray--word-at-point=, =spray--update= and =spra *** Algorithm translated from code to english -Words are split at space, tab and newline characters, and if any of the characters =.!?;= appear in a word, a blank word is appended to the current word. +Words are split at space, tab, newline, and emdash characters. If any of the characters =.!?;= appear at the end of the word, a blank word is appended to the current word. -Each word is displayed for (60 / the choosen wpm) seconds, except if the word contains : or , or is greater than 9 characters long, in which case it is displayed for twice as long. +Each word is displayed for (60 / the choosen wpm) seconds, except if the word ends with ,:— or is greater than 9 characters long, in which case it is displayed for twice as long. The accent location is chosen as the nth character in a word, depending on its length, based on the following table | length | accent position | diff --git a/spray.el b/spray.el index 836cf07..1ebdab2 100644 --- a/spray.el +++ b/spray.el @@ -159,9 +159,9 @@ (spray-mode -1)) (defun spray--word-at-point () - (skip-chars-backward "^\s\t\n") + (skip-chars-backward "^\s\t\n—") (let* ((beg (point)) - (len (skip-chars-forward "^\s\t\n")) + (len (+ (skip-chars-forward "^\s\t\n—") (skip-chars-forward "—"))) (end (point)) (accent (+ beg (cl-case len ((1) 1) @@ -177,7 +177,7 @@ (if (looking-at "\n[\s\t\n]") 3 0) (cl-case (char-before) ((?. ?! ?\? ?\;) 3) - ((?, ?:) 1) + ((?, ?: ?—) 1) (t 0)))) (move-overlay spray--accent-overlay (1- accent) accent) (move-overlay spray--base-overlay beg end) @@ -196,7 +196,7 @@ (widen) (if (eobp) (spray-mode -1) - (skip-chars-forward "\s\t\n") + (skip-chars-forward "\s\t\n—") (spray--word-at-point))))) ;; * interactive commands @@ -226,15 +226,15 @@ Returns t if spray was unpaused." (interactive) (spray-stop) (widen) - (skip-chars-forward "\s\t\n") + (skip-chars-forward "\s\t\n—") (spray--word-at-point)) (defun spray-backward-word () (interactive) (spray-stop) (widen) - (skip-chars-backward "^\s\t\n") - (skip-chars-backward "\s\t\n") + (skip-chars-backward "^\s\t\n—") + (skip-chars-backward "\s\t\n—") (spray--word-at-point)) (defun spray-faster ()