[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "Snippet" database
From: |
Masatake YAMATO |
Subject: |
Re: "Snippet" database |
Date: |
Sat, 07 Jan 2012 06:49:34 +0900 (JST) |
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
Re: "Snippet" database, Richard Riley, 2012/01/06
Re: "Snippet" database, Ted Zlatanov, 2012/01/06
Re: "Snippet" database, John Wiegley, 2012/01/07