Update elfeed-update.el

This commit is contained in:
Case Duckworth 2022-01-21 17:41:18 -06:00
parent 81fb787be4
commit 00f639319c
2 changed files with 70 additions and 69 deletions

View File

@ -76,18 +76,18 @@ See `no-littering' for examples.")
;;; Fonts
(+with-ensure-after-init
;; Set default faces
(+with-message "Setting default faces"
(let ((font-name machine-default-font)
(font-size machine-default-height)
(variable-font-name machine-variable-pitch-font)
(variable-font-size machine-variable-pitch-height))
(set-face-attribute 'default nil :family font-name
:height font-size :weight 'book)
(set-face-attribute 'italic nil :family font-name
:height font-size :slant 'italic)
(set-face-attribute 'variable-pitch nil :family variable-font-name
:height variable-font-size)))
(unless noninteractive ;; Set default faces
(+with-message "Setting default faces"
(let ((font-name machine-default-font)
(font-size machine-default-height)
(variable-font-name machine-variable-pitch-font)
(variable-font-size machine-variable-pitch-height))
(set-face-attribute 'default nil :family font-name
:height font-size :weight 'book)
(set-face-attribute 'italic nil :family font-name
:height font-size :slant 'italic)
(set-face-attribute 'variable-pitch nil :family variable-font-name
:height variable-font-size))))
;; Emoji fonts
(+with-message "Adding emoji fonts"

View File

@ -40,63 +40,64 @@
(defun +elfeed-update-command ()
(interactive)
(let ((script (expand-file-name "~/.local/bin/elfeed"))
(update-message-format "[Elfeed] Updating in the background...%s"))
(message update-message-format "")
(setq +elfeed--update-running t)
(elfeed-db-save)
(advice-add 'elfeed :override #'+elfeed--update-message)
(ignore-errors (kill-buffer "*elfeed-search*"))
(ignore-errors (kill-buffer "*elfeed-log*"))
(elfeed-db-unload)
(unless (file-exists-p script)
(make-directory (file-name-directory script) :parents)
(with-temp-buffer
(insert
(nconcat nil
"#!/usr/bin/env -S emacs --script"
;; I have to load the necessary files
"(load (locate-user-emacs-file \"early-init\"))"
"(straight-use-package 'elfeed)"
"(straight-use-package 'elfeed-org)"
"(require 'elfeed)"
"(require 'elfeed-org)"
;; And set needed variables
`("(setq rmh-elfeed-org-files '("
,(mapconcat (lambda (el)
(format "\"%s\"" el))
rmh-elfeed-org-files
" ")
"))")
;; Overwrite log function to go to stdout
"(defun elfeed-log (level fmt &rest objects)"
" (princ (format \"[%s] [%s]: %s\\n\""
" (format-time-string \"%F %T\")"
" level"
" (apply #'format fmt objects))))"
;; Load elfeed
"(elfeed-org)"
"(elfeed-db-load)"
"(elfeed)"
;; Update elfeed
"(elfeed-update)"
;; Wait to finish ... I think.
"(while (> (elfeed-queue-count-total) 0)"
" (sleep-for 5)"
" (message \"%s\" (elfeed-queue-count-total))"
" (accept-process-output))"
;; Save and garbage-collect
"(elfeed-db-save)"
"(elfeed-db-gc)"))
(write-file script))
(chmod script #o777))
(set-process-sentinel (start-process-shell-command
"Elfeed" nil script)
(lambda (a b)
(advice-remove 'elfeed #'+elfeed--update-message)
(setq +elfeed--update-running nil)
(message update-message-format
(string-trim b))))))
(let ((script (expand-file-name "~/.local/bin/elfeed-update.el"))
(update-message-format "[Elfeed] Updating in the background..."))
(with-temp-message update-message-format
(setq +elfeed--update-running t)
(elfeed-db-save)
(advice-add 'elfeed :override #'+elfeed--update-message)
(ignore-errors (kill-buffer "*elfeed-search*"))
(ignore-errors (kill-buffer "*elfeed-log*"))
(elfeed-db-unload)
(unless (file-exists-p script)
(make-directory (file-name-directory script) :parents)
(with-temp-buffer
(insert
(nconcat nil
"#!/usr/bin/env -S emacs --script"
"(setq lexical-binding t)"
;; I have to load the necessary files
"(load (locate-user-emacs-file \"early-init\"))"
"(straight-use-package 'elfeed)"
"(straight-use-package 'elfeed-org)"
"(require 'elfeed)"
"(require 'elfeed-org)"
;; And set needed variables
`("(setq rmh-elfeed-org-files '("
,(mapconcat (lambda (el)
(format "\"%s\"" el))
rmh-elfeed-org-files
" ")
"))")
;; Overwrite log function to go to stdout
"(defun elfeed-log (level fmt &rest objects)"
" (princ (format \"[%s] [%s]: %s\\n\""
" (format-time-string \"%F %T\")"
" level"
" (apply #'format fmt objects))))"
;; Load elfeed
"(elfeed-org)"
"(elfeed-db-load)"
"(elfeed)"
;; Update elfeed
"(elfeed-update)"
;; Wait to finish ... I think.
"(while (> (elfeed-queue-count-total) 0)"
" (sleep-for 5)"
" (message \"%s\" (elfeed-queue-count-total))"
" (accept-process-output))"
;; Save and garbage-collect
"(elfeed-db-save)"
"(elfeed-db-gc)"))
(write-file script))
(chmod script #o777))
(set-process-sentinel (start-process-shell-command
"Elfeed" nil script)
(lambda (a b)
(advice-remove 'elfeed #'+elfeed--update-message)
(setq +elfeed--update-running nil)
(message update-message-format
(string-trim b)))))))
(defvar +elfeed--update-timer nil "Timer for `elfeed-update-command'.")
(defvar +elfeed--update-first-time 6 "How long to wait for the first time.")