summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el1
-rw-r--r--lisp/+elfeed.el55
2 files changed, 41 insertions, 15 deletions
diff --git a/init.el b/init.el index 15b3768..3e023db 100644 --- a/init.el +++ b/init.el
@@ -1093,6 +1093,7 @@ See also `crux-reopen-as-root-mode'."
1093 "&" #'+elfeed-show-browse-generic 1093 "&" #'+elfeed-show-browse-generic
1094 "RET" #'shr-browse-url) 1094 "RET" #'shr-browse-url)
1095 (:hook #'reading-mode) 1095 (:hook #'reading-mode)
1096 (:option +elfeed--update-first-time 60)
1096 (+elfeed-update-async-mode +1))) 1097 (+elfeed-update-async-mode +1)))
1097 1098
1098(setup (:straight elfeed-org) 1099(setup (:straight elfeed-org)
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)