Where parallels cross

Interesting bits of life

YASnippet list also my html email questions please!

In an old post I shared a little hack to highlight the questions to answer in an email. It is still something I use, so that code was indeed valuable.

Today I realized that html messages don't have a text body :body-txt but a :body-html, which broke my code.

Below the improvement which relies on the useful html2text function.

(defun my/pick-questions-in-mail ()
  (-some--> mu4e-compose-parent-message
    (or (mu4e-message-field it :body-txt)
          (insert (mu4e-message-field it :body-html))
          ;; html2text drops any meaningful separator of the html
          (--> (buffer-string)
                '(("." . ".\n")
                  ("?" . "?\n")
                  ("!" . "!\n"))
                 ;; trying to skip my referenced message that starts with On 2 Jun 2024 12:35,
                 (caar (s-matched-positions-all "On [0-9] ... [0-9]\\{4\\} [0-9]\\{2\\}:[0-9]\\{2\\}," it))
                 (length it))
    (s-split "\n" it)
    (--remove (s-prefix-p "> " it) it)
    (s-join " \n " it)

Note the hacky adding of newlines and trimming of your own messages, because we want to respond only the sender questions not our own.

Happy emailing,