[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strip signature on reply without standard separator

From: Satoshi Yoshida
Subject: Re: Strip signature on reply without standard separator
Date: Sat, 22 Oct 2022 15:16:51 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Emanuel Berg <> 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 ()
    (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 "^>\
" (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.

Satoshi Yoshida

reply via email to

[Prev in Thread] Current Thread [Next in Thread]