From: DevZero <emacs@gmx.net>
To: help-gnu-emacs@gnu.org
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 [thread overview]
Message-ID: <20110117054248.GA22821@phlegeton.tartaros> (raw)
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.
next reply other threads:[~2011-01-17 5:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-17 5:42 DevZero [this message]
2011-01-19 4:55 ` Automatic inserting of M-x spook to then mail headers when emacs is only used as editor Kevin Rodgers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110117054248.GA22821@phlegeton.tartaros \
--to=emacs@gmx.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.