From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: "Snippet" database Date: Sat, 07 Jan 2012 06:49:34 +0900 (JST) Organization: Red Hat Japan, Inc. Message-ID: <20120107.064934.590252325830536875.yamato@redhat.com> References: <20120107.041328.2292730043452883798.yamato@redhat.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1325886589 5254 80.91.229.12 (6 Jan 2012 21:49:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Jan 2012 21:49:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: larsi@gnus.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 06 22:49:45 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RjHfU-00017C-K8 for ged-emacs-devel@m.gmane.org; Fri, 06 Jan 2012 22:49:44 +0100 Original-Received: from localhost ([::1]:51029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjHfU-0007UI-8A for ged-emacs-devel@m.gmane.org; Fri, 06 Jan 2012 16:49:44 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjHfR-0007UD-C9 for emacs-devel@gnu.org; Fri, 06 Jan 2012 16:49:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjHfQ-00075r-8I for emacs-devel@gnu.org; Fri, 06 Jan 2012 16:49:41 -0500 Original-Received: from mx1.redhat.com ([209.132.183.28]:42854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjHfQ-00075e-0j for emacs-devel@gnu.org; Fri, 06 Jan 2012 16:49:40 -0500 Original-Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q06LncAP011523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Jan 2012 16:49:38 -0500 Original-Received: from localhost (vpn1-6-27.sin2.redhat.com [10.67.6.27]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q06LnZ1j012074; Fri, 6 Jan 2012 16:49:36 -0500 In-Reply-To: <20120107.041328.2292730043452883798.yamato@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:147414 Archived-At: I wrote: >> In my various guises I find myself sending out the same rote email >> answer to many people. "Thanks for the patch; applied" and stuff. It >> would be nice if one could just mark the region, ask Emacs to pull it >> into a database of snippets, and then have a command that would insert >> them again. >> >> Surely something like this already exists in Emacs, but I just can't >> seem to find it. Probably looking for the wrong thing... >> >> -- >> (domestic pets only, the antidote for overdose, milk.) >> bloggy blog http://lars.ingebrigtsen.no/ >> >> > > It may be nice if the "Snippet" database feature is integrated > to abbrev, register, and bookmark machinery. > > Masatake > Here is the prototype of bookmark based snippet manager. Usage: 1. Set the region which you want to record as snippet 2. Do M-x snippet:region->bookmark 3. Do \C-x r l 4. Do [return] on the line where the snippet 5. Switch the buffer 6. \C-y (require 'bookmark) (defun snippet:region->bookmark () (interactive) (lexical-let ((snippet (buffer-substring (region-beginning) (region-end)))) (let ((bookmark-make-record-function (lambda () `((page . ,snippet) (handler . snippet:bookmark->kill-ring))))) (bookmark-set (car (split-string snippet "[\n]")))))) (defun snippet:bookmark->kill-ring (record) (kill-new (cdr (assoc 'page record)))) Masatake