1

I want to modify elfeed using this article: https://cundy.me/post/elfeed/

I cannot load the following code:

(defun concatenate-authors (authors-list)
  "Given AUTHORS-LIST, list of plists; return string of all authors
    concatenated."
  (mapconcat
   (lambda (author) (plist-get author :name))
   authors-list ", "))

(defun my-search-print-fn (entry)
  "Print ENTRY to the buffer."
  (let* ((date (elfeed-search-format-date (elfeed-entry-date entry)))
         (title (or (elfeed-meta entry :title)
                    (elfeed-entry-title entry) ""))
         (title-faces (elfeed-search--faces (elfeed-entry-tags entry)))
         (feed (elfeed-entry-feed entry))
         (feed-title
          (when feed
            (or (elfeed-meta feed :title) (elfeed-feed-title feed))))
         (entry-authors (concatenate-authors
                         (elfeed-meta entry :authors)))
         (tags (mapcar #'symbol-name (elfeed-entry-tags entry)))
         (tags-str (mapconcat
                    (lambda (s) (propertize s 'face
                                            'elfeed-search-tag-face))
                    tags ","))
         (title-width (- (window-width) 10
                         elfeed-search-trailing-width))
         (title-column (elfeed-format-column
                        title (elfeed-clamp
                               elfeed-search-title-min-width
                               title-width
                               elfeed-search-title-max-width)
                        :left))
         (authors-width 50)
         (authors-column (elfeed-format-column
                          entry-authors (elfeed-clamp
                                         elfeed-search-title-min-width
                                         authors-width
                                         100)
                          :left)))

    (insert (propertize date 'face 'elfeed-search-date-face) " ")

    (insert (propertize title-column
                        'face title-faces 'kbd-help title) " ")

    (insert (propertize authors-column
                        'face 'elfeed-search-date-face
                        'kbd-help entry-authors) " ")

    ;; (when feed-title
    ;;   (insert (propertize entry-authors
    ;; 'face 'elfeed-search-feed-face) " "))

    (when entry-authors
      (insert (propertize feed-title
                          'face 'elfeed-search-feed-face) " "))

    ;; (when tags
    ;;   (insert "(" tags-str ")"))
))

(setq elfeed-search-print-entry-function #'my-search-print-fn)

I put this code in dotspacemacs/user-init and dotspacemacs/user-config and tested it separately... the code does not work.

However, when I reload my config (SPC f e R) the code loads just fine and my elfeed gets modified. But ONLY when I reload my config... it's not working after a normal restart or start up of emacs. What's wrong?

kai90
  • 13
  • 5
  • I am not sure what you mean. Of course, after placing code in `dotspacemacs/user-config` you should reload your dotfile using `SPC f e R`, or alternatively restart Spacemacs. Do you mean it did not work even after restarting Spacemacs? – dalanicolai May 06 '23 at 09:33
  • Yes...sorry... the config does not load after restart. Only when I do SPC f e R – kai90 May 06 '23 at 10:32
  • As loading works correctly after using `SPC f e R`, I guess your init file loads successfully, incl. the `user-config` and `user-init` sections. So I guess your `elfeed-search-print-entry-function` variable gets redefined when starting and (auto)loading elfeed. Please, after restarting Spacemacs, check the value of `elfeed-search-print-entry-function` before starting and after starting 'elfeed'. If they are different then wrap your `setq` form as follows `(with-eval-after-load 'elfeed-search (setq elfeed-search-print-entry-function #'my-search-print-fn))`. – dalanicolai May 06 '23 at 11:50

1 Answers1

0

As loading works correctly after using SPC f e R, I guess your init file loads successfully, incl. the user-config and user-init sections. So I guess your elfeed-search-print-entry-function variable gets redefined when starting and (auto)loading elfeed. Please, after restarting Spacemacs, check the value of elfeed-search-print-entry-function before starting and after starting 'elfeed'. If they are different then wrap your setq form as follows

(with-eval-after-load 'elfeed-search
  (setq elfeed-search-print-entry-function #'my-search-print-fn))
dalanicolai
  • 6,108
  • 7
  • 23
  • 1
    you are right! elfeed-search-print-entry-function is overwritten in the start up... by elfeed goodies! I guess, when I find out, how to get rid of this, everything should work out fine – kai90 May 08 '23 at 16:53
  • The suggested `with-eval-after-load` does not work? – dalanicolai May 09 '23 at 05:03
  • sadly no... elfeed-goodies somehow overwrites the functions – kai90 May 09 '23 at 08:15
  • Ah okay, I wasn't aware the elfeed-goodies is actaully a package. So then try replacing `'elfeed-search` with `'elfeed-goodies'` in that `with-eval-after-load`. – dalanicolai May 09 '23 at 08:47
  • Great idea! But also no... elfeed-search-print-entry-function remains set by elfeed-goodies – kai90 May 10 '23 at 09:56
  • I removed efleed completely and loaded the packages brand new, but still elfeed-goodies came back. It's like cancer....! – kai90 May 11 '23 at 06:48
  • 1
    I have the feeling that the problem shifted from my original question. I will mark your answer as accepted and create a new question! Thank you very much! – kai90 May 17 '23 at 14:30