From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19169 invoked from network); 15 Sep 2022 23:51:56 -0000 Received: from lists.gnu.org (209.51.188.17) by inbox.vuxu.org with ESMTPUTF8; 15 Sep 2022 23:51:56 -0000 Received: from localhost ([::1]:45822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYyeA-0008Fp-Gf for ml@inbox.vuxu.org; Thu, 15 Sep 2022 19:51:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYydP-0007Vv-85 for info-gnus-english@gnu.org; Thu, 15 Sep 2022 19:51:08 -0400 Received: from pv50p00im-zteg10011501.me.com ([17.58.6.42]:33644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYydK-0006Av-UG for info-gnus-english@gnu.org; Thu, 15 Sep 2022 19:51:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1663285859; bh=pIRHkRFrgKbk+0eNrVwEjlQNs+OZzIMp01YvAXyK5dI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=wk+OQclxqKnrRfZNyDTZZjQQevZZv54rwoVH+FBnXMnIIneJO3cTnvPBKx79RwItW 3kqr5qxXYuqMkwcekjE2MXbSxH7NAEsNLMjwrTDbp33RI0xZqhcj+reXWP+HH6Aw/s axGUchduM6R5pI81Zo8SZ5lxWJsFH3peAlCi90IRjnfpTsSmhSc0F8xPG64Ge5mAtO o/KxqGDD5gYoQskARbI1KMRo60Py9zU4Gb3RzmW+3pmcDlIQ6Fd4z2WpaPUTENBmxP 2H3+2yfkCs7xy8Y8Mrs7XMaaSFUi8S8X9jEZ3u9RYyrUJYDLTWvXMoL0S3P8tQNEzE HBUZw4DOsZdaw== Received: from arch (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011501.me.com (Postfix) with ESMTPSA id 30A812E0594 for ; Thu, 15 Sep 2022 23:50:57 +0000 (UTC) From: Satoshi Yoshida To: info-gnus-english@gnu.org Subject: Re: Strip signature on reply without standard separator References: <87y1vykpl2.fsf@icloud.com> <87zggbz3ho.fsf@icloud.com> <87bksaz837.fsf@icloud.com> <87a67ul62m.fsf@dataswamp.org> <87mtbufg7e.fsf@icloud.com> <875yii2oru.fsf@dataswamp.org> <875yih6n25.fsf_-_@icloud.com> <878rnaw3tw.fsf_-_@icloud.com> <87mtbgarre.fsf@icloud.com> <87czcb6gjp.fsf@dataswamp.org> <87r10onki5.fsf@icloud.com> <8735d47zos.fsf@dataswamp.org> X-Operating-System: Linux version 5.19.8-arch1-1 Arch Linux x86_64 Date: Fri, 16 Sep 2022 08:50:56 +0900 In-Reply-To: <8735d47zos.fsf@dataswamp.org> (Emanuel Berg's message of "Wed, 07 Sep 2022 03:14:59 +0200") Message-ID: <87fsgsgpsv.fsf@icloud.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: TRL-UKFItbBUgWgAxRpKCJvC2sWWkm7E X-Proofpoint-ORIG-GUID: TRL-UKFItbBUgWgAxRpKCJvC2sWWkm7E X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.138,18.0.572,17.11.64.514.0000000_definitions?= =?UTF-8?Q?=3D2020-02-14=5F11:2020-02-14=5F02,2020-02-14=5F11,2022-02-23?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 mlxlogscore=622 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2209150152 Received-SPF: pass client-ip=17.58.6.42; envelope-from=dynamisxar@icloud.com; helo=pv50p00im-zteg10011501.me.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+ml=inbox.vuxu.org@gnu.org Sender: "info-gnus-english" Emanuel Berg writes: > Make the whole thing a function that you add to the the hook. I see. About function name, I refered to https://ayatakesi.github.io/lispref/28.2/elisp-ja.html#Setting-Hooks >> (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\ > > Here it may be a better idea to have those REs in a list and > then iterate that (a loop) instead of calling the same > function so many times. I consulted members of https://emacs-jp.github.io/ on slack. Many thanks for their kind help. (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))) (defun my-mu-cite-hook-function () (save-excursion (dolist (elm '(("^\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\\)*" ""))) (apply #'strip-signature elm)) (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:]]+\n\\)*>\ [[:blank:]]*\\(-+[[:blank:]]*\\)?%s\\(%s\\)?\\([[:blank:]]*\\(\n>\ [[:blank:]]+\\)*?\\)?[[: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-file-contents "~/.signature") (insert "\n-- \n")))) (add-hook 'mu-cite-post-cite-hook #'my-mu-cite-hook-function) -- Satoshi Yoshida