[Top][All Lists]

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

Re: Strip signature on reply without standard separator

From: Emanuel Berg
Subject: Re: Strip signature on reply without standard separator
Date: Wed, 07 Sep 2022 03:14:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Satoshi Yoshida wrote:

>> 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?

Make the whole thing a function that you add to the the hook.

Use blank lines to separate different parts.

This also makes it easier to test, you can simply call
the function.

And try out and optimize the different parts one by one.

But only do modules when it makes sense semantically, i.e.
when one can clearly say "this function does this, this other
function does something different", don't split it up just
because "this function is too long".

One way to check if it does make sense is to write names that
makes sense, when that is difficult, "hm ... what DO we call
THIS function?" then that is an indication that function isn't
a good idea.

So while in general it's good with modules but in particular
good modules are even better ;)

> (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.

underground experts united

reply via email to

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