@@ -121,8 +121,7 @@ the transformed string that is used for the speed type exercise.
121121E.g. if you always want lowercase words, set:
122122`speed-type-wordlist-transform' to `downcase' ."
123123 :type '(choice (const :tag " None" nil )
124- (function :tag " Transform function" ))
125- :group 'speed-type )
124+ (function :tag " Transform function" )))
126125
127126(defcustom speed-type-default-lang nil
128127 " Default language for training wordlists. Ask when NIL."
@@ -191,24 +190,21 @@ E.g. if you always want lowercase words, set:
191190 (const :tag " Tagabawa" bgs)
192191 (const :tag " Tagalog" tl)
193192 (const :tag " Telugu" te)
194- (const :tag " Welsh" cy))
195- :group 'speed-type )
193+ (const :tag " Welsh" cy)))
196194
197195(defcustom speed-type-replace-strings '((" “" . " \" " ) (" ”" . " \" " ) (" ‘" . " '" ) (" ’" . " '" ) (" —" . " -" ) (" –" . " -" ) (" Æ" . " Ae" ) (" æ" . " ae" ) (" »" . " \" " ) (" «" . " \" " ))
198196 " Alist of strings to replace and their replacement, in the form:
199197`(bad-string . good-string)'
200198To remove without replacement, use the form: `(bad-string . \"\" )'"
201- :type '(alist :key-type string :value-type string)
202- :group 'speed-type )
199+ :type '(alist :key-type string :value-type string))
203200
204201(defcustom speed-type-randomize t
205202 " Affects the text-picker when starting speed-type-buffer or speed-type-text.
206203
207204When non-nil it picks a random portion, otherwise it checks for existing
208205records to start from. If nothing found will take text-portion from the
209206beginning."
210- :type 'boolean
211- :group 'speed-type )
207+ :type 'boolean )
212208
213209(defcustom speed-type-downcase nil
214210 " Toggle downcasing of mistyped words."
@@ -220,8 +216,17 @@ beginning."
220216when point-move (default), moves the point one character further.
221217
222218when point-stay, stays at the current position until correct character is typed."
223- :type 'symbol
224- :group 'speed-type )
219+ :type 'symbol )
220+
221+ (defcustom speed-type-complete-all-correct nil
222+ " This flag controls the behaviour of triggering complete in speed-type session.
223+
224+ When non-nil, will complete if all characters are typed correctly (have
225+ status correct or ignore)
226+
227+ When nil, will complete when all characters have a status (any non-nil
228+ status value)."
229+ :type 'boolean )
225230
226231(defcustom speed-type-add-extra-words-on-error 0
227232 " How many new words should be added on error.
@@ -1255,9 +1260,16 @@ are color coded and stats are gathered about the typing performance."
12551260 (car (overlays-at end)))))
12561261 (move-overlay overlay (1- (overlay-end overlay)) (overlay-end overlay)) (current-buffer ))
12571262 (speed-type--diff orig new-text start end)
1258- (when (and (not (save-excursion (text-property-search-forward 'speed-type-char-status 'nil t )))
1259- (not (save-excursion (text-property-search-backward 'speed-type-char-status 'nil t )))
1260- (not (text-property-any (point-min ) (point-max ) 'speed-type-char-status 'nil )))
1263+ (when
1264+ (and (not (save-excursion (text-property-search-forward 'speed-type-char-status 'nil t )))
1265+ (not (save-excursion (text-property-search-backward 'speed-type-char-status 'nil t )))
1266+ (null speed-type--extra-words-queue)
1267+ (not (text-property-any (point-min ) (point-max ) 'speed-type-char-status 'nil ))
1268+ (or (not speed-type-complete-all-correct)
1269+ (and speed-type-complete-all-correct
1270+ (not (save-excursion (text-property-search-forward 'speed-type-char-status 'error t )))
1271+ (not (save-excursion (text-property-search-backward 'speed-type-char-status 'error t )))
1272+ (not (text-property-any (point-min ) (point-max ) 'speed-type-char-status 'error )))))
12611273 (speed-type-complete)))
12621274 (beep )
12631275 (message " End of buffer " )))))
@@ -1279,39 +1291,39 @@ and property adjusted. A new string is returned with adjusted
12791291properties."
12801292 (save-excursion
12811293 (eval `(,(or (and object 'with-temp-buffer ) 'with-current-buffer )
1282- (unless ,object (current-buffer ))
1283- (progn
1284- (when ,object (insert ,object ))
1285- (dolist (pair ',map )
1286- (let ((from (car pair))
1287- (to (cdr pair)))
1288- (goto-char (point-min ))
1289- (while (search-forward from nil t )
1290- (let* ((start (match-beginning 0 ))
1291- (end (match-end 0 ))
1292- (prop-start (previous-single-property-change start ',property speed-type--buffer (point-min )))
1293- (prop-end (next-single-property-change end ',property speed-type--buffer (point-max )))
1294- (len-from (length from))
1295- (len-to (length to))
1296- (old-property-value (get-text-property start ',property )))
1297- (replace-match to t t )
1298-
1299- (cond
1300- ; ; TO longer → extend property region
1301- ((> len-to len-from)
1302- (put-text-property
1303- prop-start (+ prop-end (- len-to len-from))
1304- ',property old-property-value))
1305-
1306- ; ; FROM longer → shrink property region
1307- ((< len-to len-from)
1308- (let ((new-prop-end (- prop-end (- len-from len-to))))
1309- (when (> new-prop-end prop-start)
1310- (put-text-property
1311- prop-start new-prop-end
1312- ',property old-property-value))))
1313- (t (put-text-property prop-start prop-end ',property old-property-value)))))))
1314- (when ,object (buffer-string )))))))
1294+ (unless ,object (current-buffer ))
1295+ (progn
1296+ (when ,object (insert ,object ))
1297+ (dolist (pair ',map )
1298+ (let ((from (car pair))
1299+ (to (cdr pair)))
1300+ (goto-char (point-min ))
1301+ (while (search-forward from nil t )
1302+ (let* ((start (match-beginning 0 ))
1303+ (end (match-end 0 ))
1304+ (prop-start (previous-single-property-change start ',property speed-type--buffer (point-min )))
1305+ (prop-end (next-single-property-change end ',property speed-type--buffer (point-max )))
1306+ (len-from (length from))
1307+ (len-to (length to))
1308+ (old-property-value (get-text-property start ',property )))
1309+ (replace-match to t t )
1310+
1311+ (cond
1312+ ; ; TO longer → extend property region
1313+ ((> len-to len-from)
1314+ (put-text-property
1315+ prop-start (+ prop-end (- len-to len-from))
1316+ ',property old-property-value))
1317+
1318+ ; ; FROM longer → shrink property region
1319+ ((< len-to len-from)
1320+ (let ((new-prop-end (- prop-end (- len-from len-to))))
1321+ (when (> new-prop-end prop-start)
1322+ (put-text-property
1323+ prop-start new-prop-end
1324+ ',property old-property-value))))
1325+ (t (put-text-property prop-start prop-end ',property old-property-value)))))))
1326+ (when ,object (buffer-string )))))))
13151327
13161328(cl-defun speed-type--setup
13171329 (content-buffer text &key file-name title author lang n-words randomize continue-fn add-extra-word-content-fn replay-fn go-next-fn syntax-table fldf)
0 commit comments