Preview messages in Summary buffer

7 views
Skip to first unread message

mikael.s...@gmail.com

unread,
Jun 23, 2020, 8:40:45 AM6/23/20
to
Hi,

Just wanting to share a QnD hack I cobbled together when I was supposed to be marking theses today. It's still plenty rough around the edges but as a proof of concept it works reasonably well.

TL;DR: I wanted to be able to preview messages in the summary buffer so that I did not have to open an article window just to realise that it wasn't the message I was after. So I bound this to the key 'v' in gnus-summary-mode-map:

(defconst oxpecker-preview-lines 10)

(defun oxpecker-remove-empty-lines ()
(save-excursion
(message-goto-body)
(while (re-search-forward "^ *\n" nil t)
(replace-match ""))))

(defun oxpecker-wash-message (msg-buf)
(with-temp-buffer
(let (beg end)
(insert-buffer msg-buf)
(beginning-of-buffer)
(oxpecker-remove-empty-lines)
(message-goto-body)
(setq beg (point))
(insert "\n")
(forward-line oxpecker-preview-lines)
(setq end (point))
(buffer-substring beg end))))

(defun oxpecker-preview-message ()
(interactive)
(let ((gnus-inhibit-treatment t))
(save-window-excursion
(gnus-summary-select-article))
(let ((end (point-at-eol))
(msg (oxpecker-wash-message gnus-article-buffer)))
(momentary-string-display msg end ?v "Previewing Message. Press any key to continue."))))

TODO: It still opens the article window, I would prefer if I could to this entirely in the background. =gnus-request-article-this-buffer= would help, but then I need to parse the article in its entirety and that sounds like work.

/Mikael
Reply all
Reply to author
Forward
0 new messages