diff options
author | Case Duckworth | 2022-01-21 09:29:49 -0600 |
---|---|---|
committer | Case Duckworth | 2022-01-21 09:29:49 -0600 |
commit | 40a6acaf56f5525c683942665b9231085412cda9 (patch) | |
tree | 3598849de1be917c39f9200b1f5b1b1637874005 /lisp | |
parent | Change display of tab-bar buttons (diff) | |
download | emacs-40a6acaf56f5525c683942665b9231085412cda9.tar.gz emacs-40a6acaf56f5525c683942665b9231085412cda9.zip |
Being working on +elfeed-update-async
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+elfeed.el | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index ef93347..4a874c3 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el | |||
@@ -40,7 +40,7 @@ | |||
40 | 40 | ||
41 | (defun +elfeed-update-command () | 41 | (defun +elfeed-update-command () |
42 | (interactive) | 42 | (interactive) |
43 | (let ((script (expand-file-name "~/.local/bin/elfeed"))) | 43 | (let ((script (expand-file-name "~/.local/bin/elfeed-update.el"))) |
44 | (message "[Elfeed] Updating in the background.") | 44 | (message "[Elfeed] Updating in the background.") |
45 | (setq +elfeed--update-running t) | 45 | (setq +elfeed--update-running t) |
46 | (elfeed-db-save) | 46 | (elfeed-db-save) |
@@ -51,21 +51,46 @@ | |||
51 | (unless (file-exists-p script) | 51 | (unless (file-exists-p script) |
52 | (make-directory (file-name-directory script) :parents) | 52 | (make-directory (file-name-directory script) :parents) |
53 | (with-temp-buffer | 53 | (with-temp-buffer |
54 | (insert "(progn\n" | 54 | (insert |
55 | " (load (locate-user-emacs-file \"early-init\"))\n" | 55 | (nconcat nil |
56 | " (straight-use-package 'elfeed)\n" | 56 | "#!/usr/bin/env -S emacs --script" |
57 | " (require 'elfeed)\n" | 57 | ;; I have to load the necessary files |
58 | " (elfeed)\n" | 58 | "(load (locate-user-emacs-file \"early-init\"))" |
59 | " (elfeed-update)\n" | 59 | "(straight-use-package 'elfeed)" |
60 | " (while (> (elfeed-queue-count-total) 0)\n" | 60 | "(straight-use-package 'elfeed-org)" |
61 | " (sleep-for 5)\n" | 61 | "(require 'elfeed)" |
62 | " (message \"%s\" (elfeed-queue-count-total))\n" | 62 | "(require 'elfeed-org)" |
63 | " (accept-process-output))\n" | 63 | ;; And set needed variables |
64 | " (elfeed-db-save-safe)\n" | 64 | `("(setq rmh-elfeed-org-files '(" |
65 | " (elfeed-db-gc-safe))") | 65 | ,(mapconcat (lambda (el) |
66 | (write-file script))) | 66 | (format "\"%s\"" el)) |
67 | rmh-elfeed-org-files | ||
68 | " ") | ||
69 | "))") | ||
70 | ;; Overwrite log function to go to stdout | ||
71 | "(defun elfeed-log (level fmt &rest objects)" | ||
72 | " (princ (format \"[%s] [%s]: %s\\n\"" | ||
73 | " (format-time-string \"%F %T\")" | ||
74 | " level" | ||
75 | " (apply #'format fmt objects))))" | ||
76 | ;; Load elfeed | ||
77 | "(elfeed-org)" | ||
78 | "(elfeed-db-load)" | ||
79 | "(elfeed)" | ||
80 | ;; Update elfeed | ||
81 | "(elfeed-update)" | ||
82 | ;; Wait to finish ... I think. | ||
83 | "(while (> (elfeed-queue-count-total) 0)" | ||
84 | " (sleep-for 5)" | ||
85 | " (message \"%s\" (elfeed-queue-count-total))" | ||
86 | " (accept-process-output))" | ||
87 | ;; Save and garbage-collect | ||
88 | "(elfeed-db-save)" | ||
89 | "(elfeed-db-gc)")) | ||
90 | (write-file script)) | ||
91 | (chmod script #o777)) | ||
67 | (set-process-sentinel (start-process-shell-command | 92 | (set-process-sentinel (start-process-shell-command |
68 | "Elfeed" nil (concat "emacs --script " script)) | 93 | "Elfeed" nil script) |
69 | (lambda (a b) | 94 | (lambda (a b) |
70 | (advice-remove 'elfeed #'+elfeed--update-message) | 95 | (advice-remove 'elfeed #'+elfeed--update-message) |
71 | (setq +elfeed--update-running nil) | 96 | (setq +elfeed--update-running nil) |