mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-10 19:23:03 +03:00
feat(mail): move signature when necessary
This commit is contained in:
parent
7de55fa15f
commit
460e6a8d32
2 changed files with 117 additions and 1 deletions
|
|
@ -93,3 +93,41 @@
|
|||
(CMS
|
||||
(sign)
|
||||
(encrypt))))
|
||||
|
||||
(setq my/message-signature-on-top '("@etu.ru"))
|
||||
|
||||
(defun my/message-insert-signature-need-on-top ()
|
||||
(let ((parts (split-string
|
||||
(string-join
|
||||
(list
|
||||
(message-fetch-field "to")
|
||||
(message-fetch-field "cc")
|
||||
(message-fetch-field "bcc"))
|
||||
", ")
|
||||
", ")))
|
||||
(and
|
||||
(seq-some
|
||||
(lambda (rule)
|
||||
(seq-some
|
||||
(lambda (part)
|
||||
(string-match-p rule part))
|
||||
parts))
|
||||
my/message-signature-on-top)
|
||||
t)))
|
||||
|
||||
(defun my/message-maybe-fix-signature (&rest _)
|
||||
(when (my/message-insert-signature-need-on-top)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward message-signature-separator nil t)
|
||||
(move-beginning-of-line 0)
|
||||
(kill-region (point) (point-max)))
|
||||
(message-goto-body)
|
||||
(when (re-search-forward (rx "sign=pgpmime") nil t)
|
||||
(forward-line))
|
||||
(insert (current-kill 0))
|
||||
(insert "\n\n")
|
||||
(set-buffer-modified-p nil))))
|
||||
|
||||
(with-eval-after-load 'notmuch-mua
|
||||
(advice-add #'notmuch-mua-reply :after #'my/message-maybe-fix-signature))
|
||||
|
|
|
|||
80
Mail.org
80
Mail.org
|
|
@ -450,7 +450,8 @@ Finally the proper notmuch settings:
|
|||
(lambda () (display-line-numbers-mode 0))))
|
||||
#+end_src
|
||||
|
||||
The file to which this is tangled is read in the init.el.
|
||||
The file is read in =init.el=.
|
||||
|
||||
** Saved filters and keybindings
|
||||
I want to have the saved filters available in both notmuch interface as as keybindings. So a bit more of abusing org tables.
|
||||
|
||||
|
|
@ -543,6 +544,83 @@ And the following does the same for my general.el definer:
|
|||
(sign)
|
||||
(encrypt))))
|
||||
#+end_src
|
||||
** Tuning signature
|
||||
By default, =message.el= inserts the signature at the bottom of the message, like this:
|
||||
|
||||
#+begin_example
|
||||
<message text>
|
||||
|
||||
Person <person@mail.org> writes:
|
||||
|
||||
> Stuff
|
||||
|
||||
--
|
||||
Yours,
|
||||
me
|
||||
#+end_example
|
||||
|
||||
This creates issues with certain email clients. For instance, MS Exchange often just cuts the text at =Person <person@mail.org>....=, so there's no way to see the signature from the UI.
|
||||
|
||||
What's more, MS Exchange, Gmail and other such clients add the signature before the quotation block, like that:
|
||||
|
||||
#+begin_example
|
||||
<message text>
|
||||
|
||||
--
|
||||
Yours,
|
||||
me
|
||||
|
||||
Person <person@mail.org> writes:
|
||||
|
||||
> Stuff
|
||||
#+end_example
|
||||
|
||||
So here I modifiy the citation function to insert the signature like in the second example for certain cases.
|
||||
|
||||
FIrst, determine whether it is necessary to do so:
|
||||
#+begin_src emacs-lisp
|
||||
(setq my/message-signature-on-top '("@etu.ru"))
|
||||
|
||||
(defun my/message-insert-signature-need-on-top ()
|
||||
(let ((parts (split-string
|
||||
(string-join
|
||||
(list
|
||||
(message-fetch-field "to")
|
||||
(message-fetch-field "cc")
|
||||
(message-fetch-field "bcc"))
|
||||
", ")
|
||||
", ")))
|
||||
(and
|
||||
(seq-some
|
||||
(lambda (rule)
|
||||
(seq-some
|
||||
(lambda (part)
|
||||
(string-match-p rule part))
|
||||
parts))
|
||||
my/message-signature-on-top)
|
||||
t)))
|
||||
#+end_src
|
||||
|
||||
Then advice the =notmuch-mua-reply= function:
|
||||
#+begin_src emacs-lisp
|
||||
(defun my/message-maybe-fix-signature (&rest _)
|
||||
(when (my/message-insert-signature-need-on-top)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward message-signature-separator nil t)
|
||||
(move-beginning-of-line 0)
|
||||
(kill-region (point) (point-max)))
|
||||
(message-goto-body)
|
||||
(when (re-search-forward (rx "sign=pgpmime") nil t)
|
||||
(forward-line))
|
||||
(insert (current-kill 0))
|
||||
(insert "\n\n")
|
||||
(set-buffer-modified-p nil))))
|
||||
|
||||
(with-eval-after-load 'notmuch-mua
|
||||
(advice-add #'notmuch-mua-reply :after #'my/message-maybe-fix-signature))
|
||||
#+end_src
|
||||
|
||||
* mailcap
|
||||
mailcap file is a file which defines how to read to different MIME types. Notmuch also uses it, so why not keep it here.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue