I didn't get this to work via the elfeed-show-mode-hook
. I don't really fully understand what is going on, but I think it is something to do with the margins set by olivetti mode not activating until after the buffer is displayed, but elfeed renders the buffer before that and so the HTML renderer doesn't get the updated text width.
However, I was able to solve it another way by setting the elfeed-show-entry-switch
function. Elfeed calls this function after it sets up the *elfeed-entry*
buffer. If this is given a function that switches to the buffer, turns on olivetti-mode and then does a refresh, it all seems to work:
(defun elfeed-olivetti (buff)
(switch-to-buffer buff)
(olivetti-mode)
(elfeed-show-refresh))
(setq elfeed-show-entry-switch 'elfeed-olivetti)
I guess this is a bit inefficient because it does the refresh twice, but I haven't noticed any slowdown when using it.