From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: DevZero Newsgroups: gmane.emacs.help 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 Message-ID: <20110117054248.GA22821@phlegeton.tartaros> Reply-To: help-gnu-emacs@gnu.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1295243010 1505 80.91.229.12 (17 Jan 2011 05:43:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 17 Jan 2011 05:43:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 17 06:43:27 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PehsE-0004wA-GM for geh-help-gnu-emacs@m.gmane.org; Mon, 17 Jan 2011 06:43:26 +0100 Original-Received: from localhost ([127.0.0.1]:43939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PehsE-0005wB-2O for geh-help-gnu-emacs@m.gmane.org; Mon, 17 Jan 2011 00:43:26 -0500 Original-Received: from [140.186.70.92] (port=33936 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pehrh-0005w6-AM for help-gnu-emacs@gnu.org; Mon, 17 Jan 2011 00:42:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pehrg-00028s-2U for help-gnu-emacs@gnu.org; Mon, 17 Jan 2011 00:42:53 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:50066) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Pehrf-00028i-M0 for help-gnu-emacs@gnu.org; Mon, 17 Jan 2011 00:42:52 -0500 Original-Received: (qmail invoked by alias); 17 Jan 2011 05:42:48 -0000 Original-Received: from dslb-092-072-035-113.pools.arcor-ip.net (EHLO phlegeton.tartaros) [92.72.35.113] by mail.gmx.net (mp070) with SMTP; 17 Jan 2011 06:42:48 +0100 X-Authenticated: #110074317 X-Provags-ID: V01U2FsdGVkX1/pNYhZl67pNX1soaTCw8lZrddwoISvn/OUPs2BGi bsKIEUglq207sT Original-Received: by phlegeton.tartaros (Postfix, from userid 500) id 66CB58F; Mon, 17 Jan 2011 06:42:48 +0100 (CET) Content-Disposition: inline User-GPG: GPG-Encrypted and signed messages preferred! User-GPG-Key-ID: 0x9B8D89A6 User-GPG-Key-Server: wwwkeys.de.pgp.net User-GeekCode: GE/ITd-s:aC+++UL++++++++L+++E+++W+++N++oK++w---O-M--V--PS+++PE++Y+PGP++t++5--X++R-tv--b++DI+D++G++e+++hr+y** X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78507 Archived-At: 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.