email-eww

Emacs library to send region or eww buffer by email
git clone https://logand.com/git/email-eww.git/
Log | Files | Refs

commit 3ccf709d460060f44197e60f12b86b32e7370b45
parent d732a64c21d777f9f3dc77d1b86aca1ef4faada8
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 14 Sep 2025 23:45:52 +0200

various updates

Diffstat:
Memail-eww.el | 159++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 129 insertions(+), 30 deletions(-)

diff --git a/email-eww.el b/email-eww.el @@ -11,6 +11,8 @@ ;;; Inspired by ;;; http://kitchingroup.cheme.cmu.edu/blog/2014/06/08/Better-integration-of-org-mode-and-email/ +(require 'eww) + (defcustom email-eww-from "" "Sender email address." @@ -123,12 +125,15 @@ (unless (= (point) (point-max)) (forward-char 1)))) -(defun clean-up-faz () ;; TODO Artikel auf einer Seite lesen +(defun clean-up-faz () ;; TODO Artikel auf einer Seite lesen @@@ cuts out end (forward-line 2) (let ((start (point))) (goto-char (point-max)) - (or (search-backward "Mehr zum Thema" nil t) - (search-backward "* Submit Submit")) + (or + (search-backward "Quelle:" nil t) + (search-backward "Mehr zum Thema" nil t) + (search-backward "* Submit Submit") + ) (forward-line -1) (delete-region (point) (point-max)) (goto-char (point-max)) @@ -308,7 +313,7 @@ (delete-region (point) (point-max)) (message-goto-body)) -(defun clean-up-euractiv () +(defun clean-up-euractiv () ;; TODO Better (forward-line 1) (let ((start (point))) (cond @@ -316,7 +321,7 @@ (beginning-of-line) (backward-paragraph 3) (delete-region (point) start)) - ((search-forward "Content-Type:") + ((search-forward "Content-Type:" nil t) (backward-paragraph 3) (delete-region (point) start))) ;; tail @@ -362,9 +367,83 @@ ) (message-goto-body)) +(defun clean-up-fefe () ;; TODO append external links + (forward-line 1) + (let ((start (point))) + (search-forward "Fragen? Antworten! Siehe auch: Alternativlos" nil t) + (beginning-of-line) + (forward-paragraph) + (delete-region (point) start) + ;; tail + (goto-char (point-max)) + (search-backward "ganzer Monat" nil t) + (beginning-of-line) + (forward-line -1) + (delete-region (point) (point-max)) + ) + (message-goto-body)) + +(defun clean-up-nixos-discourse () + (forward-line 1) + (let ((start (point))) + (forward-paragraph) + (delete-region (point) start) + ;; tail + (goto-char (point-max)) + (backward-paragraph 2) + (delete-region (point) (point-max)) + ) + (message-goto-body)) + +;; TODO techdirt until ^Hide this + +(defun clean-up-aljazeera () ;; TODO better + (forward-line 1) + (let ((start (point))) + (search-forward "Submit" nil t) + (search-forward "Submit" nil t) + (search-forward "Submit" nil t) + (forward-paragraph) + (delete-region (point) start) + ;; tail + (goto-char (point-max)) + (search-backward "Recommended Stories" nil t) + (beginning-of-line) + (forward-line -1) + (delete-region (point) (point-max)) + ) + (message-goto-body)) + +(defun clean-up-neovlivni () + (forward-line 1) + (let ((start (point))) + (forward-paragraph 3) + (delete-region (point) start) + ;; tail + (goto-char (point-max)) + (when (search-backward "Sdílet článek" nil t) + (beginning-of-line) + (delete-region (point) (point-max)))) + (message-goto-body)) + +(defun clean-up-sputnik () + (forward-line 1) + (let ((start (point))) + (search-forward "Subscribe" nil t) + (beginning-of-line) + (forward-paragraph 2) + (delete-region (point) start) + ;; tail + (goto-char (point-max)) + (search-backward "Sputnik International" nil t) + (backward-paragraph 2) + (delete-region (point) (point-max)) + ) + (message-goto-body)) + (defun email-eww () (interactive) - (let ((content (buffer-string)) + (let ((content (buffer-substring-no-properties (point-min) (point-max))) (title (or (plist-get eww-data :title) (buffer-name (current-buffer)))) (url (plist-get eww-data :url))) @@ -413,34 +492,54 @@ (clean-up-euractiv)) ((string-match "infomigrants.net" url) (clean-up-infomigrants)) + ((string-match "blog.fefe.de" url) + (clean-up-fefe)) + ((string-match "discourse.nixos.org" url) + (clean-up-nixos-discourse)) + ((string-match "aljazeera.com" url) + (clean-up-aljazeera)) + ((string-match "neovlivni.cz" url) + (clean-up-neovlivni)) + ((string-match "sputnikglobe.com" url) + (clean-up-sputnik)) ) (goto-char (point-max)) (delete-blank-lines) (message-goto-to) (current-buffer))) -(defun email-w3m (url) - (when url - (let ((b (get-buffer-create url))) - (shell-command (concat "w3m -dump " (shell-quote-argument url)) b b) - (with-current-buffer b - (email-region (point-min) (point-max)) - (message-goto-body) - (insert url) - (insert "\n\n") - (cond - ((or - (string-match "serverfault.com" url) - (string-match "stackexchange.com" url) - (string-match "stackoverflow.com" url) - (string-match "superuser.com" url) - ) - (search-forward "Ask Question" nil t) - (beginning-of-line) - (backward-paragraph 1) - (beginning-of-line) - (forward-line 3) - (delete-region (point) start) - (clean-up-stackoverflow))) - (message-goto-to))))) +;; (defun email-w3m (url) +;; (when url +;; (let ((b (get-buffer-create url))) +;; (shell-command (concat "w3m -dump " (shell-quote-argument url)) b b) +;; (with-current-buffer b +;; (email-region (point-min) (point-max)) +;; (message-goto-body) +;; (insert url) +;; (insert "\n\n") +;; (cond +;; ((or +;; (string-match "serverfault.com" url) +;; (string-match "stackexchange.com" url) +;; (string-match "stackoverflow.com" url) +;; (string-match "superuser.com" url) +;; ) +;; (search-forward "Ask Question" nil t) +;; (beginning-of-line) +;; (backward-paragraph 1) +;; (beginning-of-line) +;; (forward-line 3) +;; (delete-region (point) start) +;; (clean-up-stackoverflow))) +;; (message-goto-to))))) +;;(email-w3m "https://superuser.com/questions/199286/organize-email-by-date-using-procmail") +;;(email-w3m "https://unix.stackexchange.com/questions/3092/organize-email-by-date-using-procmail-or-maildrop") +;;(email-w3m "https://stackoverflow.com/questions/5882840/procmail-move-to-folder-and-mark-as-read") +;;(email-w3m "https://serverfault.com/questions/403873/how-to-create-default-subfolders-using-procmail-with-maildir-and-postfix-that") +;;subject \n\n Ask Question\n ... Your Answer\n + +;; TODO websend url|eww url + clean up + eww vs w3m|lynx|... +;; TODO pull feeds and websend direct to maildir (sorted by YYYY-MM?) +;; TODO url substitutions e.g. -> onion or old.reddit + (provide 'email-eww)