From ca3d5c2b75135d552450eafb85f0dc25cecca530 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Thu, 12 Oct 2023 15:15:50 +0300 Subject: [PATCH] feat(mail): capitalize formal pronouns --- .emacs.d/mail.el | 30 ++++++++++++++++++++++++++++++ Mail.org | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/.emacs.d/mail.el b/.emacs.d/mail.el index 9f2f9f2..c352464 100644 --- a/.emacs.d/mail.el +++ b/.emacs.d/mail.el @@ -112,6 +112,36 @@ (add-hook 'notmuch-mua-send-hook #'my/message-ensure-subject) +(defvar my/ru-formal-pronous + '("вы" "вас" "вам" "вами" "ваш" "ваша" "ваше" "ваши" "вашего" + "вашей" "вашему" "вашим" "вашем" "вашеми")) + +(defvar my/ru-formal-pronous-regex + (regexp-opt my/ru-formal-pronous 'words)) + +(defun my/message-ensure-capitalized-formal-pronouns () + (interactive) + (save-excursion + (message-goto-body) + (cl-block nil + (let ((case-fold-search nil) + confirmed) + (while (re-search-forward my/ru-formal-pronous-regex nil t) + (let* ((match (match-string 0)) + (capitalized (capitalize match)) + (beg (match-beginning 0)) + (end (match-end 0))) + (if (or confirmed + (y-or-n-p (format "Replace %s with %s? " + match capitalized))) + (progn + (delete-region beg end) + (insert capitalized) + (setq confirmed t)) + (cl-return)))))))) + +(add-hook 'notmuch-mua-send-hook #'my/message-ensure-capitalized-formal-pronouns) + (defun my/ensure-password () (interactive) (my/password-store-get "Job/Digital/Email/pvkorytov@etu.ru")) diff --git a/Mail.org b/Mail.org index 97b7a97..a3f9275 100644 --- a/Mail.org +++ b/Mail.org @@ -577,6 +577,38 @@ Then advice the =notmuch-mua-reply= function: (add-hook 'notmuch-mua-send-hook #'my/message-ensure-subject) #+end_src +** Capitalize formal pronous +#+begin_src emacs-lisp +(defvar my/ru-formal-pronous + '("вы" "вас" "вам" "вами" "ваш" "ваша" "ваше" "ваши" "вашего" + "вашей" "вашему" "вашим" "вашем" "вашеми")) + +(defvar my/ru-formal-pronous-regex + (regexp-opt my/ru-formal-pronous 'words)) + +(defun my/message-ensure-capitalized-formal-pronouns () + (interactive) + (save-excursion + (message-goto-body) + (cl-block nil + (let ((case-fold-search nil) + confirmed) + (while (re-search-forward my/ru-formal-pronous-regex nil t) + (let* ((match (match-string 0)) + (capitalized (capitalize match)) + (beg (match-beginning 0)) + (end (match-end 0))) + (if (or confirmed + (y-or-n-p (format "Replace %s with %s? " + match capitalized))) + (progn + (delete-region beg end) + (insert capitalized) + (setq confirmed t)) + (cl-return)))))))) + +(add-hook 'notmuch-mua-send-hook #'my/message-ensure-capitalized-formal-pronouns) +#+end_src ** Ensure password is loaded Otherwise =msmtp= may call =pinentry= while Emacs is locked, which means EXWM can't process the password window.