[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Automatic inserting of M-x spook to then mail headers when emacs is only
From: |
DevZero |
Subject: |
Automatic inserting of M-x spook to then mail headers when emacs is only used as editor |
Date: |
Mon, 17 Jan 2011 06:42:48 +0100 |
hello everybody
i like to insert the M-x spook into the mail headers to every outgoing message
but as i'm not using gnus but mutt as my mua this seemed to be a bit tricky,
but i finally managed it (learning quite some elisp on the way). Now i would
like to hear some comments/improvements from the gurus here if this is the
right way or something to avoid (and of course to share this maybe even useful
code snipped). Especially the inserting of the spook (with-temp-buffer) looks
suspicious to me - but i did not find any other way to do it...
first the function:
(defun replace-spook ()
"Insert nsa-spook."
(interactive "r")
(save-excursion
(goto-line 7)
(let* ((spook (with-temp-buffer (spook) (buffer-string)))
(output (replace-regexp-in-string "\n" "" spook)))
(insert (concat "Spook: " output "\n")))
)
)
then i set up emacs to start up mail-mode when a mutt-temp-file is opened:
(setq auto-mode-alist (cons '("/tmp/mutt-" . mail-mode) auto-mode-alist))
and finally the replacing
(add-hook 'mail-mode-hook 'replace-spook)
Improvements in which i failed up to now:
* add a search to insert spook after a special header (and skip it if not
found) and not just hardcoded after line 7
* convince emacs that the buffer has not changed right after the mail-mode-hook
has been executed (even if it has because of the new header - but that change
is irrelevant at that time)
Greetz!
dz
--
Apples have meant trouble since eden.
- Automatic inserting of M-x spook to then mail headers when emacs is only used as editor,
DevZero <=