[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/greader ab4f91c27d 1/2: greader.el: greader-study-mode
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/greader ab4f91c27d 1/2: greader.el: greader-study-mode added. |
|
Date: |
Sun, 19 Nov 2023 12:58:01 -0500 (EST) |
branch: externals/greader
commit ab4f91c27db4d334f198f902f2dcec4140cd08fc
Author: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
greader.el: greader-study-mode added.
When this minor-mode is active, reading resumes from the beginning of
buffer or active region.
---
greader.el | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/greader.el b/greader.el
index 8119bc0716..9ab09be976 100644
--- a/greader.el
+++ b/greader.el
@@ -1573,7 +1573,7 @@ the reading process, returning nil in such cases."
;; Check if a valid command is returned.
(when command
;; Calls the function returned by greader-continuous-guess-function.
-;; We check that the point is not at the end of the buffer.
+ ;; We check that the point is not at the end of the buffer.
(when (eobp)
(goto-char (- (point-max) 1)))
(funcall command)
@@ -1596,6 +1596,7 @@ called the `info-scroll-up' function instead of finishing
reading."
:lighter " continuous"
(if greader-continuous-mode
(progn
+ (greader-study-mode -1)
(unless (greader-continuous-guess-function)
(let ((error-string
(concat
@@ -1608,6 +1609,34 @@ this major mode to the variable
`greader-continuous-modes'")))
#'greader-continuous-call-function 0 t))
(remove-hook 'greader-before-finish-functions
#'greader-continuous-call-function t)))
+;; greader-study-mode
+;; This is the complementary mode of "greader-continuous-mode", and
+;; is used to repeatedly read the contents of a buffer or part of
+;; it.
+
+;; greader-study-restart is the function that will be added to the hook
+;; `greader-before-finish-functions'.
+;; The function simply returns to the beginning of the buffer or the
+;; active region and runs `greader-read'.
+(defun greader-study-restart ()
+ "restart reading of buffer or region."
+ (if greader-region-mode
+ (goto-char (region-beginning))
+ (goto-char (point-min)))
+ (greader-read) t)
+
+;; greader-study-mode
+(define-minor-mode greader-study-mode
+ "In study-mode, reading of buffer will restart continuously.
+If `greader-region-mode' is enabled, restart will behave accordingly."
+ :lighter " study"
+ (if greader-study-mode
+ (progn
+ (greader-continuous-mode -1)
+ (add-hook 'greader-before-finish-functions
+ #'greader-study-restart 0 t))
+ (remove-hook 'greader-before-finish-functions
+ #'greader-study-restart t)))
(provide 'greader)
;;; greader.el ends here