From: Satoshi Yoshida <dynamisxar@icloud.com>
To: info-gnus-english@gnu.org
Subject: Re: Strip signature on reply without standard separator
Date: Fri, 16 Sep 2022 08:50:56 +0900 [thread overview]
Message-ID: <87fsgsgpsv.fsf@icloud.com> (raw)
In-Reply-To: <8735d47zos.fsf@dataswamp.org> (Emanuel Berg's message of "Wed, 07 Sep 2022 03:14:59 +0200")
Emanuel Berg <incal@dataswamp.org> 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:]]+\\)*<?%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-file-contents "~/.signature")
(insert "\n-- \n"))))
(add-hook 'mu-cite-post-cite-hook #'my-mu-cite-hook-function)
--
Satoshi Yoshida
next prev parent reply other threads:[~2022-09-15 23:51 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 4:28 Satoshi Yoshida
2022-08-09 5:56 ` Emanuel Berg
2022-08-09 8:34 ` Satoshi Yoshida
2022-08-09 8:52 ` Emanuel Berg
2022-08-09 9:25 ` Satoshi Yoshida
2022-09-11 9:46 ` Satoshi Yoshida
2022-09-12 6:45 ` Satoshi Yoshida
2022-09-14 6:08 ` Emanuel Berg
2022-09-14 7:48 ` Satoshi Yoshida
2022-08-11 6:41 ` Satoshi Yoshida
2022-08-11 14:48 ` Satoshi Yoshida
2022-08-12 3:06 ` Satoshi Yoshida
2022-08-11 15:26 ` Satoshi Yoshida
2022-08-24 2:30 ` Satoshi Yoshida
2022-08-24 2:37 ` Emanuel Berg
2022-08-24 3:55 ` Satoshi Yoshida
2022-08-24 5:28 ` Emanuel Berg
2022-08-24 22:26 ` Michael Heerdegen
2022-08-25 2:10 ` Satoshi Yoshida
2022-08-25 3:04 ` Strip signature on reply without standard separator [solved] Satoshi Yoshida
2022-08-25 6:46 ` Emanuel Berg
2022-08-27 6:59 ` Strip signature on reply without standard separator Satoshi Yoshida
2022-08-27 7:19 ` Satoshi Yoshida
2022-09-04 0:48 ` Satoshi Yoshida
2022-09-04 2:04 ` Emanuel Berg
2022-09-06 23:36 ` Satoshi Yoshida
2022-09-07 1:14 ` Emanuel Berg
2022-09-15 23:50 ` Satoshi Yoshida [this message]
2022-09-19 0:58 ` Emanuel Berg
2022-09-21 9:15 ` Satoshi Yoshida
2022-09-21 13:15 ` Emanuel Berg
2022-09-23 21:36 ` Satoshi Yoshida
2022-09-24 15:29 ` Emanuel Berg
2022-09-25 3:32 ` Satoshi Yoshida
2022-09-25 3:41 ` Emanuel Berg
2022-09-26 8:03 ` Satoshi Yoshida
2022-09-26 12:28 ` Emanuel Berg
2022-10-22 6:16 ` Satoshi Yoshida
2022-10-23 23:45 ` Emanuel Berg
2022-09-25 9:42 ` Michael Heerdegen
2022-09-26 7:56 ` Satoshi Yoshida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fsgsgpsv.fsf@icloud.com \
--to=dynamisxar@icloud.com \
--cc=info-gnus-english@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).