diff options
Diffstat (limited to 'lisp/+elfeed.el')
-rw-r--r-- | lisp/+elfeed.el | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index 47ada47..b2a578b 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el | |||
@@ -52,21 +52,46 @@ | |||
52 | (unless (file-exists-p script) | 52 | (unless (file-exists-p script) |
53 | (make-directory (file-name-directory script) :parents) | 53 | (make-directory (file-name-directory script) :parents) |
54 | (with-temp-buffer | 54 | (with-temp-buffer |
55 | (insert "(progn\n" | 55 | (insert |
56 | " (load (locate-user-emacs-file \"early-init\"))\n" | 56 | (nconcat nil |
57 | " (straight-use-package 'elfeed)\n" | 57 | "#!/usr/bin/env -S emacs --script" |
58 | " (require 'elfeed)\n" | 58 | ;; I have to load the necessary files |
59 | " (elfeed)\n" | 59 | "(load (locate-user-emacs-file \"early-init\"))" |
60 | " (elfeed-update)\n" | 60 | "(straight-use-package 'elfeed)" |
61 | " (while (> (elfeed-queue-count-total) 0)\n" | 61 | "(straight-use-package 'elfeed-org)" |
62 | " (sleep-for 5)\n" | 62 | "(require 'elfeed)" |
63 | " (message \"%s\" (elfeed-queue-count-total))\n" | 63 | "(require 'elfeed-org)" |
64 | " (accept-process-output))\n" | 64 | ;; And set needed variables |
65 | " (elfeed-db-save-safe)\n" | 65 | `("(setq rmh-elfeed-org-files '(" |
66 | " (elfeed-db-gc-safe))") | 66 | ,(mapconcat (lambda (el) |
67 | (write-file script))) | 67 | (format "\"%s\"" el)) |
68 | rmh-elfeed-org-files | ||
69 | " ") | ||
70 | "))") | ||
71 | ;; Overwrite log function to go to stdout | ||
72 | "(defun elfeed-log (level fmt &rest objects)" | ||
73 | " (princ (format \"[%s] [%s]: %s\\n\"" | ||
74 | " (format-time-string \"%F %T\")" | ||
75 | " level" | ||
76 | " (apply #'format fmt objects))))" | ||
77 | ;; Load elfeed | ||
78 | "(elfeed-org)" | ||
79 | "(elfeed-db-load)" | ||
80 | "(elfeed)" | ||
81 | ;; Update elfeed | ||
82 | "(elfeed-update)" | ||
83 | ;; Wait to finish ... I think. | ||
84 | "(while (> (elfeed-queue-count-total) 0)" | ||
85 | " (sleep-for 5)" | ||
86 | " (message \"%s\" (elfeed-queue-count-total))" | ||
87 | " (accept-process-output))" | ||
88 | ;; Save and garbage-collect | ||
89 | "(elfeed-db-save)" | ||
90 | "(elfeed-db-gc)")) | ||
91 | (write-file script)) | ||
92 | (chmod script #o777)) | ||
68 | (set-process-sentinel (start-process-shell-command | 93 | (set-process-sentinel (start-process-shell-command |
69 | "Elfeed" nil (concat "emacs --script " script)) | 94 | "Elfeed" nil script) |
70 | (lambda (a b) | 95 | (lambda (a b) |
71 | (advice-remove 'elfeed #'+elfeed--update-message) | 96 | (advice-remove 'elfeed #'+elfeed--update-message) |
72 | (setq +elfeed--update-running nil) | 97 | (setq +elfeed--update-running nil) |