branch: externals/greader
commit c621404b46c763cd9cfa4c18ef828fac8a601847
Author: Michelangelo Rodriguez <michelangelo.rodrig...@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodrig...@gmail.com>

    greader-audiobook.el: function `greader-audiobook--get-block-size' 
simplified.
---
 greader-audiobook.el | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/greader-audiobook.el b/greader-audiobook.el
index c0b480eb00..6766b66b50 100644
--- a/greader-audiobook.el
+++ b/greader-audiobook.el
@@ -147,6 +147,7 @@ Only the final report will be printed."
   :type '(boolean))
 
 ;; functions
+
 (defun greader-audiobook--get-block ()
   "Get a block of text in current buffer.
 This function uses `greader-audiobook-block-size' to determine the
@@ -157,8 +158,7 @@ Return a cons with start and end of the block or nil if at 
end of the buffer."
 
   (save-excursion
     (let ((start (point))
-         (end (point-max))
-         (words (count-words (point) (point-max))))
+         (end (point-max)))
       (if (assq major-mode greader-audiobook-modes)
          (progn
            (search-forward
@@ -167,26 +167,19 @@ Return a cons with start and end of the block or nil if 
at end of the buffer."
            (setq end (point)))
        (pcase greader-audiobook-block-size
          ((pred numberp)
-          (when
-              (< (+ (point) greader-audiobook-block-size) (point-max))
-            (cond
-             ((> greader-audiobook-block-size 0)
-              (goto-char (+ (point) greader-audiobook-block-size))
-              (when (thing-at-point 'sentence)
-                (forward-sentence))
-              (setq end (point))))))
+          (when (> greader-audiobook-block-size 0)
+            (goto-char (+ (point) greader-audiobook-block-size))
+            (when (thing-at-point 'sentence)
+              (forward-sentence)
+              (setq end (point)))))
          ((pred stringp)
           (cond
            ((> (string-to-number greader-audiobook-block-size) 0)
-            (when (< (*
-                      (string-to-number greader-audiobook-block-size)
-                      (greader-get-rate))
-                     words)
-              (forward-word (* (string-to-number
-                                greader-audiobook-block-size)
-                               (greader-get-rate)))
-              (when (thing-at-point 'sentence)
-                (forward-sentence)))
+            (forward-word (* (string-to-number
+                              greader-audiobook-block-size)
+                             (greader-get-rate)))
+            (when (thing-at-point 'sentence)
+              (forward-sentence))
             (setq end (point)))))
          (_
           (error "Cannot determine the block size"))))

Reply via email to