Under GNU Emacs 24.4.1, in Message Mode, C-c C-w runs
message-insert-signature, which inserts the file
message-signature-file at the end of the buffer, if such a signature is not already present.
How can I extend the function
message-insert-signature so that to maintain its current functionalities but add one such that, when prefixing the command with C-u (which gives C-u C-c C-w), the signature is rather inserted at point (e.g. for mails where there are attachments which I wish to be AFTER the signature)?
It would be easy to define a function to insert
"\n-- \n" and perform
(insert-file-contents signature-file) at point, and to bind it to a new key combination, but my muscle memory is set to
C-u C-c C-w from my previous use of VM, and I thought it could be the same for other users.
The code of the function
message-insert-signature bound by default to
C-c C-w is interactive with parameters
(&optional force), which suggests that one could "force" the signature to be inserted, but I don't understand how the
(interactive (list 0)) works:
(defun message-insert-signature (&optional force) "Insert a signature. See documentation for variable `message-signature'." (interactive (list 0)) (let* ((signature (cond ((and (null message-signature) (eq force 0)) (save-excursion (goto-char (point-max)) (not (re-search-backward message-signature-separator nil t)))) ((and (null message-signature) force) t) ((functionp message-signature) (funcall message-signature)) ((listp message-signature) (eval message-signature)) (t message-signature))) signature-file) (setq signature (cond ((stringp signature) signature) ((and (eq t signature) message-signature-file) (setq signature-file (if (and message-signature-directory ;; don't actually use the signature directory ;; if message-signature-file contains a path. (not (file-name-directory message-signature-file))) (expand-file-name message-signature-file message-signature-directory) message-signature-file)) (file-exists-p signature-file)))) (when signature (goto-char (point-max)) ;; Insert the signature. (unless (bolp) (insert "\n")) (when message-signature-insert-empty-line (insert "\n")) (insert "-- \n") (if (eq signature t) (insert-file-contents signature-file) (insert signature)) (goto-char (point-max)) (or (bolp) (insert "\n")))))