0

I am trying to do two things for Elfeed Summary:

  1. Automatically update the feeds when starting Elfeed Summary.
  2. Automatically hide the feeds without unread articles when starting Elfeed Summary.

Number one is already covered and works nicely with:

(add-hook 'elfeed-summary-mode-hook #'elfeed-summary-update)

But when I try to do the same for number two with:

(add-hook 'elfeed-summary-mode-hook #'elfeed-summary-toggle-only-unread)

Elfeed Summary doesn't start, and I get the following error in my *Messages*:

find-class: Wrong type argument: class-p, nil

If you would be kind enough to tell me what I've done wrong, I'd really appreciate it as I'm still fairly new to Emacs and can't seem to find an answer anywhere.

Update following @NickD (thanks!) advice:

Doing M-x toggle-debug-on-error before M-x elfeed-summary shows the following backtrace:

Debugger entered--Lisp error: (wrong-type-argument class-p nil)
  signal(wrong-type-argument (class-p nil))
  find-class(nil error)
  slot-exists-p(nil group)
  elfeed-summary--get-folding-state()
  elfeed-summary--refresh()
  elfeed-summary-toggle-only-unread()
  run-hooks(change-major-mode-after-body-hook elfeed-summary-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook elfeed-summary-mode-hook))
  run-mode-hooks(elfeed-summary-mode-hook)
  elfeed-summary-mode()
  (if (eq major-mode 'elfeed-summary-mode) nil (elfeed-summary-mode))
  (let* ((inhibit-read-only t) (render-data (elfeed-summary--render-params tree)) (elfeed-summary--unread-padding (length (number-to-string (nth 0 render-data)))) (elfeed-summary--total-padding (length (number-to-string (nth 1 render-data))))) (erase-buffer) (set (make-local-variable 'elfeed-summary--tree) tree) (if (eq major-mode 'elfeed-summary-mode) nil (elfeed-summary-mode)) (let* ((type0 'magt-insert-heading) (section1 (funcall (if (class-p type0) type0 (or (cdr ...) 'magit-section)) :type (or (and (class-p type0) (car ...)) type0) :value nil :start (point-marker) :parent magit-insert-section--parent))) (eieio-oset section1 'hidden (let ((value (run-hook-with-args-until-success 'magit-section-set-visibility-hook section1))) (if value (eq value 'hide) (let ((incarnation ...)) (if incarnation (eieio-oref incarnation ...) (let ... ...)))))) (let ((magit-insert-section--current section1) (magit-insert-section--parent section1) (magit-insert-section--oldroot (or magit-insert-section--oldroot (if magit-insert-section--parent nil (prog1 magit-root-section ...))))) (catch 'cancel-section (let ((_ section1)) (if tree nil (insert "🍃")) (mapc #'elfeed-summary--render-item tree)) (run-hooks 'magit-insert-section-hook) (magit-insert-child-count section1) (set-marker-insertion-type (eieio-oref section1 'start) t) (let* ((end (eieio-oset section1 ... ...)) (class-map (eieio-oref section1 ...)) (magit-map (intern ...)) (forge-map (intern ...)) (map (and class-map ...))) (if map nil (setq map (or ... ...)) (eieio-oset section1 'keymap map)) (save-excursion (goto-char (eieio-oref section1 ...)) (while (< ... end) (let ... ... ... ...)))) (if (eq section1 magit-root-section) (let ((magit-section-cache-visibility nil)) (magit-section-show section1)) (eieio-oset (eieio-oref section1 'parent) 'children (nconc (eieio-oref ... ...) (list section1))))) section1)) (widget-setup))
  elfeed-summary--render(((group (params (:title . "Websites") (:elements (query . :all))) (face) (children (feed (feed . #s(elfeed-feed :id "https://sachachua.com/blog/category/emacs/feed" :url "https://sachachua.com/blog/category/emacs/feed" :title "Sacha Chua - category - emacs" :author nil :meta (:title "Sacha Chua" :last-modified "Tue, 16 May 2023 00:45:58 GMT" :etag "W/\"6462d246-18303\"" :canonical-url "https://sachachua.com/blog/category/emacs/feed/"))) (unread . 0) (total . 0) (faces elfeed-search-title-face) (tags))))))
  elfeed-summary()
  funcall-interactively(elfeed-summary)
  call-interactively(elfeed-summary record nil)
  command-execute(elfeed-summary record)
  execute-extended-command(nil "elfeed-summary" "elfeed-su")
  funcall-interactively(execute-extended-command nil "elfeed-summary" "elfeed-su")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
2
  • 1
    Do M-x toggle-debug-on-error, then try starting it again. You should get a backtrace: cut-and-paste the backtrace into your question. That will allow people to figure out what's wrong.
    – NickD
    Commented May 18, 2023 at 15:08
  • I just did that, thank you. :)
    – Carapuce
    Commented May 18, 2023 at 16:34

1 Answer 1

1

After reading elfeed-summary.el a few more times, I finally found a solution:

(defun news ()
  (interactive)
  (elfeed-summary)
  (elfeed-summary-update)
  (setq-local elfeed-summary--only-unread
          (not elfeed-summary--only-unread))
  (elfeed-summary--refresh))

It starts Elfeed Summary and automatically updates all the feeds while only showing unread ones. Just what I tried to do!

There might be a more optimal way of doing this, but this works without any error so I'm happy. :)

Thanks again to @NickD for teaching me about M-x toggle-debug-on-error!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.