summaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorQuentin Aristote <quentin@aristote.fr>2021-11-20 16:24:19 +0100
committerQuentin Aristote <quentin@aristote.fr>2021-11-20 16:24:19 +0100
commitb5c66e3691d9a49e6d39990914cdc54ead4e4ac1 (patch)
treef736cb73dcd70f549eac399b3e54d3eeb71c908b /local
parenta5ac2f51962ea78a63ff981438f212d646999b92 (diff)
split update-entries into two commands update-region and update-buffer
Diffstat (limited to 'local')
-rw-r--r--local/bibli-paris/bibli-paris.el33
1 files changed, 23 insertions, 10 deletions
diff --git a/local/bibli-paris/bibli-paris.el b/local/bibli-paris/bibli-paris.el
index 2f33e53..6580bba 100644
--- a/local/bibli-paris/bibli-paris.el
+++ b/local/bibli-paris/bibli-paris.el
@@ -289,24 +289,37 @@ sequentially. Terribly inefficient but works."
(deferred:call 'goto-char pom)
(deferred:nextc it 'bibli-paris/update-entry))))))
-(defun bibli-paris/update-entries-batch ()
- "Update all entries' schedules and quotes, by batches so as to prevent
-emacs from opening too many files."
- (let ((poms (org-map-entries (lambda ()
- `(,(point) . ,(bibli-paris/get-entry-recnum))))))
+(defun bibli-paris/update-entries-batch (scope)
+ "Update schedules and quotes, by batches so as to prevent emacs from opening
+too many files, for every entry in the SCOPE (see the documentation entry for
+org-map-entries)"
+ (let ((pom-recnum-seq (org-map-entries
+ (lambda ()
+ ;; (point) is incremented to prevent off-by-one
+ ;; errors when navigating the buffer
+ `(,(+ 5 (point)) . ,(bibli-paris/get-entry-recnum)))
+ nil scope)))
+ (message "%s" pom-recnum-seq)
(deferred:$
(deferred:next (lambda () (message "Update started.")))
(deferred:loop
- (seq-partition (seq-reverse poms) bibli-paris/max-asynchronous-processes)
+ (seq-partition (seq-reverse pom-recnum-seq)
+ bibli-paris/max-asynchronous-processes)
'bibli-paris/async-update-entries-at-points)
- (deferred:nextc it 'bibli-paris/sort)
+ ;; (deferred:nextc it 'bibli-paris/sort)
(deferred:nextc it (lambda () (message "Update done."))))))
;;;###autoload
-(defun bibli-paris/update-entries ()
- "Update all entries' schedules and quotes."
+(defun bibli-paris/update-region ()
+ "Update the schedules and quotes of the entries in the current region."
(interactive)
- (bibli-paris/update-entries-batch))
+ (bibli-paris/update-entries-batch 'region))
+
+;;;###autoload
+(defun bibli-paris/update-buffer ()
+ "Update the schedules and quotes of the entries in the current buffer."
+ (interactive)
+ (bibli-paris/update-entries-batch nil))
;; import entries