summary refs log tree commit diff stats
path: root/lisp/+message.el
blob: b8bc234611a795ca76fcd52035c6d0a63dfa8ca4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
;;; +message.el --- Extra message-mode functions -*- lexical-binding: t; -*-

;;; Commentary:

;;; Code:

;; Thanks to Alex Schroeder for this!
;; https://www.emacswiki.org/emacs/Change_Signature_Dynamically

(defun +message-check-for-signature-change (&rest ignore)
  "Check for a change in the To: or Cc: fields"
  (when (and (message--in-tocc-p)
             (not (buffer-narrowed-p)))
    (save-excursion
      (goto-char (point-max))
      (let ((end (point)))
        (when (re-search-backward message-signature-separator nil t)
          (delete-region (1- (match-beginning 0)) end)))
      (message-insert-signature))))

(defun +message-signature-setup ()
  (make-local-variable 'after-change-functions)
  (push '+message-check-for-signature-change after-change-functions))

(provide '+message)
;;; +message.el ends here