From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/79056 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: Re: using templates to write articles (email) Date: Fri, 10 Jun 2011 11:53:25 -0700 Message-ID: <87ei318qmy.fsf@ericabrahamsen.net> References: <87fwnhd0mx.fsf@yun.yagibdah.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1307732064 25251 80.91.229.12 (10 Jun 2011 18:54:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Jun 2011 18:54:24 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M27355@lists.math.uh.edu Fri Jun 10 20:54:20 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QV6qZ-0006Bx-IT for ding-account@gmane.org; Fri, 10 Jun 2011 20:54:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1QV6q6-0001EF-MK; Fri, 10 Jun 2011 13:53:50 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1QV6q5-0001E7-7X for ding@lists.math.uh.edu; Fri, 10 Jun 2011 13:53:49 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1QV6q3-0008Dg-IO for ding@lists.math.uh.edu; Fri, 10 Jun 2011 13:53:48 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1QV6q0-0007cy-Jk for ding@gnus.org; Fri, 10 Jun 2011 20:53:44 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QV6q0-0005yl-4V for ding@gnus.org; Fri, 10 Jun 2011 20:53:44 +0200 Original-Received: from 63.226.249.211 ([63.226.249.211]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Jun 2011 20:53:44 +0200 Original-Received: from eric by 63.226.249.211 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Jun 2011 20:53:44 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 63.226.249.211 User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:WOIoxjiyRxmpOn1ScJQ7LocxoZQ= X-Spam-Score: -3.7 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:79056 Archived-At: lee writes: > Hi, > > is there some sort of support built into gnus for writing articles > (email) from templates? Such templates would contain either headers or a > body, or a combination of both. > > So far, I´ve created templates as plain text files, and when writing an > email from the template, I delete everything in the composing buffer and > do an insert-file to read the template into the buffer. This works fine, > and perhaps there´s some support for templates already built in, which > would make using templates more convenient? I don't know of anything built in, but I wrote the following function to do something like a mail merge. It's very primitive, but could serve as the basis for what you need. --8<---------------cut here---------------start------------->8--- (defun my-mail-merge (names buffer subject from marker) "This is a bit of a mess, but it's something like a mail merge. Variable containing names should be a list of two-element lists, in the format (\"Name\" \"email address\")." (interactive "XVariable containing names: \nbBuffer to slurp: \nsSubject: \nsFrom: \nsMarker: ") (dolist (n names) (compose-mail (nth 1 n) ; to address subject `(("From" . ,from)) ; all other headers nil nil nil nil) ; don't remember (insert-buffer-substring (get-buffer buffer)) (message-goto-body) (perform-replace marker (nth 0 n) nil nil nil) ; insert name (message-send-and-exit))) --8<---------------cut here---------------end--------------->8--- "marker" here is basically just something like XXXXX, that gets replaced with the name. The logical next step would be to have it read data from a file instead of a variable, and then have the top line of the file set the markers for each field, like so: {{name}},{{salutation}},{{email}} John Doe,Dear,j.doe@gmail.com Then use those markers in a template, and have the call to perform-replace loop once for each marker. Hope that provides food for thought, Eric