[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: Mon, 26 Sep 2022 17:03:52 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Emanuel Berg <> writes:

> Satoshi Yoshida wrote:
>> I understand. As for me, putting ";;; -*- lexical-binding:
>> t -*-" is difficult. Because the file (.gnus.el or .emacs)
>> isn't new. It consists of my code and the other parts that
>> already exists. If I (or someone) put ";;; -*-
>> lexical-binding: t -*-", the other parts will be
>> influenced too.
>> So I want to leave my code as it is. Thank you anyway.
> Tell him ...

I see. I'll do so if I can. Thank you very much.

(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-sig (re &optional rep)
  (or rep (setq rep ""))
  (goto-char (point-min))
  (while (re-search-forward re nil t)
    (replace-match rep)))

(defun my-mu-cite-hook-function ()
    (goto-char (point-min))
    (re-search-forward "^\\(\n-- \n\\(.*\n\\)*\\)" nil t)
    (let ((my-sig (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-sig (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) ""))
              (m-addr (match-string 3)))
          (strip-sig (apply #'format "^\\(>[[:blank:]]+\n\\)*>\
" (mapcar #'regexp-quote (list first-name middle-last-name m-addr))))))
      (strip-sig "^\\(>[>[:blank:]]+\n\\)+\\'")             
      (goto-char (point-max))
      (ignore-errors (insert my-sig)))))

(add-hook 'mu-cite-post-cite-hook #'my-mu-cite-hook-function)

Satoshi Yoshida

reply via email to

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