Emanuel Berg <in...@dataswamp.org> writes: > I'm sure you can polish that code every day for the rest of > 2022 but if it works it looks good enough to me.
Fixed some problems. (setq mu-cite-prefix-format '("> ")) (setq mu-cite-cited-prefix-regexp "^[^[:blank:]\n<>]+>+[[:blank:]]*") (setq mu-cite-top-format '(from " writes:\n\n")) (defun strip-signature (regexp &optional replacement) (or replacement (setq replacement "")) (goto-char (point-min)) (while (re-search-forward regexp nil t) (replace-match replacement))) (defun my-mu-cite-hook-function () (save-excursion (goto-char (point-min)) (re-search-forward "^\\(\n-- \n\\(.*\n\\)*\\)" nil t) (let ((my-signature (match-string 1))) (dolist (e '(("^\n-- \n\\(.*\n\\)*") ("^\\([^[:blank:]\n<>]+>.*\\)" "> \\1") ("^\\([^\n>].+\n\n\\)\\(>[>[:blank:]]+\n\\)+" "\\1") ("^> >" ">>") ("^> -- \n\\(>.*\n\\)*") ("^\\(>[[:blank:]]+\n\\)+> \\(best\\( regards\ \\| wishes\\)?\\|cheers\\|\\(good\\)?bye\\|good luck\\|\\(kind \\|warm\ \\(est\\)? \\)?regards\\|respectfully\\|\\(yours \\)?sincerely\\( yours\ \\)?\\|thank you\\( very much\\)?\\|\\(many \\)?thanks\\( in advance\ \\| very much\\)?\\),[[:blank:]]*\n\\(>.*\n\\)*"))) (strip-signature (car e) (cadr e))) (goto-char (point-min)) (when (re-search-forward "^\"?\\([^[:blank:]\n<>\"]+\\)\ \\([^\n<>\"]+\\)?\"? <\\([^\n<>\"]+\\)> writes:" nil t) (let ((first-name (match-string 1)) (middle-last-name (or (match-string 2) "")) (mail-address (match-string 3))) (strip-signature (apply #'format "^>\ [[:blank:]]*\\(-+[[:blank:]]*\\)?%s\\(%s\\)?\\([[:blank:]]*\\(\n>\ [[:blank:]]+\\)*<?%s>?\\)?[[:blank:]]*\n\\(>[>[:blank:]]+\n\\)*\\'\ " (mapcar #'regexp-quote (list first-name middle-last-name mail-address)))))) (strip-signature "^\\(>[>[:blank:]]+\n\\)+\\'") (goto-char (point-max)) (ignore-errors (insert my-signature))))) (add-hook 'mu-cite-post-cite-hook #'my-mu-cite-hook-function) I put this code on web additionally the cases of Mew and Wanderlust. Though it's a Japanese site, please use translation site if you need. https://zenn.dev/satoshiy/articles/mu-cite-strip-signature -- Satoshi Yoshida