about summary refs log tree commit diff stats
path: root/lisp/+elfeed.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+elfeed.el')
-rw-r--r--lisp/+elfeed.el88
1 files changed, 45 insertions, 43 deletions
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index ac316c4..8f7f17a 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el
@@ -60,49 +60,51 @@
60 (make-directory (file-name-directory script) :parents) 60 (make-directory (file-name-directory script) :parents)
61 (with-temp-buffer 61 (with-temp-buffer
62 (insert 62 (insert
63 (prin1-to-string ;; Print the following s-expression to a string 63 (let ((print-level nil)
64 `(progn 64 (print-length nil))
65 ;; Set up the environment 65 (prin1-to-string ;; Print the following s-expression to a string
66 (setq lexical-binding t) 66 `(progn
67 (load (locate-user-emacs-file "early-init")) 67 ;; Set up the environment
68 (dolist (pkg '(elfeed elfeed-org)) 68 (setq lexical-binding t)
69 (straight-use-package pkg) 69 (load (locate-user-emacs-file "early-init"))
70 (require pkg)) 70 (dolist (pkg '(elfeed elfeed-org))
71 ;; Copy variables from current environment 71 (straight-use-package pkg)
72 (progn 72 (require pkg))
73 ,@(cl-loop for copy-var in '(rmh-elfeed-org-files 73 ;; Copy variables from current environment
74 elfeed-db-directory 74 (progn
75 elfeed-curl-program-name 75 ,@(cl-loop for copy-var in '(rmh-elfeed-org-files
76 elfeed-use-curl 76 elfeed-db-directory
77 elfeed-curl-extra-arguments 77 elfeed-curl-program-name
78 elfeed-enclosure-default-dir) 78 elfeed-use-curl
79 collect `(progn (message "%S = %S" ',copy-var ',(symbol-value copy-var)) 79 elfeed-curl-extra-arguments
80 (setq ,copy-var ',(symbol-value copy-var))))) 80 elfeed-enclosure-default-dir)
81 ;; Define new variables for this environment 81 collect `(progn (message "%S = %S" ',copy-var ',(symbol-value copy-var))
82 (progn 82 (setq ,copy-var ',(symbol-value copy-var)))))
83 ,@(cl-loop for (new-var . new-val) in '((elfeed-curl-max-connections . 4)) 83 ;; Define new variables for this environment
84 collect `(progn (message "%S = %S" ',new-var ',new-val) 84 (progn
85 (setq ,new-var ',new-val)))) 85 ,@(cl-loop for (new-var . new-val) in '((elfeed-curl-max-connections . 4))
86 ;; Redefine `elfeed-log' to log everything 86 collect `(progn (message "%S = %S" ',new-var ',new-val)
87 (defun elfeed-log (level fmt &rest objects) 87 (setq ,new-var ',new-val))))
88 (princ (format "[%s] [%s]: %s\n" 88 ;; Redefine `elfeed-log' to log everything
89 (format-time-string "%F %T") 89 (defun elfeed-log (level fmt &rest objects)
90 level 90 (princ (format "[%s] [%s]: %s\n"
91 (apply #'format fmt objects)))) 91 (format-time-string "%F %T")
92 ;; Run elfeed 92 level
93 (elfeed-org) 93 (apply #'format fmt objects))))
94 (elfeed) 94 ;; Run elfeed
95 (elfeed-db-load) 95 (elfeed-org)
96 (elfeed-update) 96 (elfeed)
97 ;; Wait for `elfeed-update' to finish 97 (elfeed-db-load)
98 (while (> (elfeed-queue-count-total) 0) 98 (elfeed-update)
99 (sleep-for 5) 99 ;; Wait for `elfeed-update' to finish
100 (message "%s" (elfeed-queue-count-total)) 100 (while (> (elfeed-queue-count-total) 0)
101 (accept-process-output)) 101 (sleep-for 5)
102 ;; Garbage collect and save the database 102 (message "%s" (elfeed-queue-count-total))
103 (elfeed-db-gc) 103 (accept-process-output))
104 (elfeed-db-save) 104 ;; Garbage collect and save the database
105 (princ (format ,update-message-format "done."))))) 105 (elfeed-db-gc)
106 (elfeed-db-save)
107 (princ (format ,update-message-format "done."))))))
106 (write-file script)) 108 (write-file script))
107 (chmod script #o777) 109 (chmod script #o777)
108 (message update-message-format "start") 110 (message update-message-format "start")