[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/greader 0fc5020e7f 1/6: Implementation of greader-queue
From: |
ELPA Syncer |
Subject: |
[elpa] externals/greader 0fc5020e7f 1/6: Implementation of greader-queue-mode started. |
Date: |
Wed, 27 Sep 2023 03:58:15 -0400 (EDT) |
branch: externals/greader
commit 0fc5020e7f4ea2b08491826c6fdf70b711daaf75
Author: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
Implementation of greader-queue-mode started.
Infrastructure functions written.
---
greader.el | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/greader.el b/greader.el
index 321342b9ba..853be2f7d2 100644
--- a/greader.el
+++ b/greader.el
@@ -350,6 +350,8 @@ This only happens if the variables `greader-start-region'
and
(remove-hook 'greader-before-finish-functions #'greader-widen)
(remove-hook 'greader-after-stop-hook #'greader-widen)))
+
+
(defun greader-set-register ()
"Set the `?G' register to the point in current buffer."
(when greader-use-prefix
@@ -1223,5 +1225,76 @@ So you can use this command like a player, if you press
<left> you
(greader-set-register)
(greader-read))
+;; greader-queue-mode
+;; This minor mode enables an alternative reading mode, which
+;; works with blocks of text instead of the buffer in a linear fashion.
+(defvar greader-queue nil
+ "This is the variable that contains the queue.
+each element is formed by a cons, whose form is 'start-position
+. end-position'.")
+(defvar greader-queue-current-element nil
+"Represent the current item in the queue (as index).")
+;; Questa funzione aggiunge un elemento alla coda.
+(defun greader-queue-add-element (&optional start end)
+ "Add an item to the queue.
+If START and END are nil, check if the region is active.
+If the region is not active either, then it throws an error."
+ (interactive)
+ (unless (and start end)
+ (if (region-active-p)
+ (setq start (region-beginning) end (region-end))
+ (user-error "Nothing to add")))
+ (add-to-list 'greader-queue (cons start end) t)
+ (unless greader-queue-current-element
+ (setq greader-queue-current-element 0)))
+
+;; This function removes an item from the queue.
+(defun greader-queue-remove-element (&optional index)
+ "Remove the item in INDEX.
+Se INDEX รจ nil, usa la variabile `greader-queue-current-element'."
+ (interactive)
+ (unless index
+ (setq index greader-queue-current-element))
+ (when (>= index (length greader-queue))
+ (user-error "Index out of range"))
+ (setq greader-queue (seq-remove-at-position greader-queue index)))
+
+;; This function gets the text linked to an element of the
+;; queue.
+(defun greader-queue-get-element (&optional index)
+ "return the text associated with a queue item.
+If INDEX is nil, use `greader-queue-current-element'."
+ (unless index
+ (setq index greader-queue-current-element))
+ (when (>= index (length greader-queue))
+ (user-error "Index out of range"))
+ (buffer-substring (car (elt greader-queue index)) (cdr (elt
+ greader-queue
+ index))))
+
+;; This function returns the next item in the queue. If
+;; the current element is the last one, then it returns nil.
+(defun greader-queue-get-next-element ()
+ "return the next item in the queue.
+If the current element is the last one, then return nil."
+ (unless greader-queue-current-element
+ (setq greader-queue-current-element 0))
+ (if (equal (1+ greader-queue-current-element) (length
+ greader-queue))
+ nil
+ (setq greader-queue-current-element (1+ greader-queue-current-element))
+ (greader-queue-get-element)))
+
+;; This function returns the previous item in the queue, if it is
+;; the first one, returns it.
+(defun greader-queue-get-prev-element ()
+ "Return the previous item in the queue.
+If the current element is the first, it returns it."
+ (unless greader-queue-current-element
+ (setq greader-queue-current-element 0))
+ (if (> greader-queue-current-element 0)
+ (setq greader-queue-current-element (1-
+ greader-queue-current-element)))
+ (greader-queue-get-element))
(provide 'greader)
;;; greader.el ends here
- [elpa] externals/greader updated (19b094782c -> b8269b6b13), ELPA Syncer, 2023/09/27
- [elpa] externals/greader 216c049729 5/6: greader-mode: disable greader-queue-mode., ELPA Syncer, 2023/09/27
- [elpa] externals/greader de57f4c165 2/6: Merge branch 'master' into greader-queue, ELPA Syncer, 2023/09/27
- [elpa] externals/greader b8269b6b13 6/6: greader-queue-mode implemented., ELPA Syncer, 2023/09/27
- [elpa] externals/greader f32177f68c 4/6: Merge branch 'master' into greader-queue, ELPA Syncer, 2023/09/27
- [elpa] externals/greader 0fc5020e7f 1/6: Implementation of greader-queue-mode started.,
ELPA Syncer <=
- [elpa] externals/greader e274d759e7 3/6: Merge branch 'master' into greader-queue, ELPA Syncer, 2023/09/27