[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: |
Wed, 07 Sep 2022 08:36:18 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) |
Emanuel Berg <incal@dataswamp.org> writes:
> 1. Split into functions with names that explain what they do.
>
> 2. Instead of `replace-regexp', use
>
> (while (re-search-forward RE nil t)
> (replace-match STR) )
I see. Thank you. Is this fix right?
(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 replacement)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(replace-match replacement)))
(add-hook 'mu-cite-post-cite-hook
(lambda ()
(save-excursion
(strip-signature "^\n-- \n\\(.*\n\\)*" "")
(strip-signature "^\\([^[:blank:]\n<>]+>.*\\)" "> \\1")
(strip-signature "^\\([^\n>].+\n\n\\)\\(>[[:blank:]]+\n\
\\)+" "\\1")
(strip-signature "^> >" ">>")
(strip-signature "^> -- .*\n\\(>.*\n\\)*" "")
(strip-signature "^\\(>[[: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\\)*" "")
(goto-char (point-min))
(re-search-forward "^\"?\\([^[:blank:]\n<>]+\\)\
\\([^\n<>]+\\)?\"? <\\([^\n<>]+\\)> writes:" nil t)
(setq first-name (match-string 1))
(setq middle-last-name (match-string 2))
(setq mail-address (match-string 3))
(strip-signature (format "^\\(>[[:blank:]]+\n\\)*>\
[[:blank:]]*\\(-+[[:blank:]]*\\)?%s\\(%s\\)?\\([[:blank:]]*\\(\n>\
[[:blank:]]+\\)*<?%s>?\\)?[[:blank:]]*\n\\(>[[:blank:]]+\n\\)*\
\\'" first-name middle-last-name mail-address) "")
(strip-signature "^\\(>[>[:blank:]]+\n\\)+\\'" "")
(ignore-errors
(goto-char (point-max))
(insert-file-contents "~/.signature")
(insert "\n-- \n"))
(goto-line 1)
(delete-blank-lines)
(set-window-start () 1))))
--
Satoshi Yoshida
- Re: Strip signature on reply without standard separator, Satoshi Yoshida, 2022/09/03
- Re: Strip signature on reply without standard separator, Emanuel Berg, 2022/09/03
- Re: Strip signature on reply without standard separator,
Satoshi Yoshida <=
- Re: Strip signature on reply without standard separator, Emanuel Berg, 2022/09/06
- Re: Strip signature on reply without standard separator, Satoshi Yoshida, 2022/09/15
- Re: Strip signature on reply without standard separator, Emanuel Berg, 2022/09/18
- Re: Strip signature on reply without standard separator, Satoshi Yoshida, 2022/09/21
- Re: Strip signature on reply without standard separator, Emanuel Berg, 2022/09/21
- Re: Strip signature on reply without standard separator, Satoshi Yoshida, 2022/09/23
- Re: Strip signature on reply without standard separator, Emanuel Berg, 2022/09/24
- Re: Strip signature on reply without standard separator, Satoshi Yoshida, 2022/09/24
- Re: Strip signature on reply without standard separator, Emanuel Berg, 2022/09/24
- Re: Strip signature on reply without standard separator, Satoshi Yoshida, 2022/09/26