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?

3
  • 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? Commented May 6, 2023 at 9:33
  • Yes...sorry... the config does not load after restart. Only when I do SPC f e R
    – kai90
    Commented May 6, 2023 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)). Commented May 6, 2023 at 11:50

2 Answers 2

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))
7
  • 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
    Commented May 8, 2023 at 16:53
  • The suggested with-eval-after-load does not work? Commented May 9, 2023 at 5:03
  • sadly no... elfeed-goodies somehow overwrites the functions
    – kai90
    Commented May 9, 2023 at 8: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. Commented May 9, 2023 at 8:47
  • 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
    Commented May 17, 2023 at 14:30
0

Future-me here: I found that has to edit the elfeed layer to make the custom elfeed-search-print-entry-function work.

This layer can be found here: .emacs.d/layers/+readers/elfeed/

I looked in config.el and packages.el and deleted all functions and variables containing the word "goodies".

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.