unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* "Snippet" database
@ 2012-01-06 18:47 Lars Magne Ingebrigtsen
  2012-01-06 19:08 ` Drew Adams
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-01-06 18:47 UTC (permalink / raw)
  To: emacs-devel

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/




^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: "Snippet" database
  2012-01-06 18:47 "Snippet" database Lars Magne Ingebrigtsen
@ 2012-01-06 19:08 ` Drew Adams
  2012-01-06 19:13 ` Masatake YAMATO
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Drew Adams @ 2012-01-06 19:08 UTC (permalink / raw)
  To: 'Lars Magne Ingebrigtsen', emacs-devel

> It would be nice if one could just...

That's what enhancement requests are for: `M-x report-emacs-bug'.
(Yes, that is for enhancement requests as well as bug reports.)




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 18:47 "Snippet" database Lars Magne Ingebrigtsen
  2012-01-06 19:08 ` Drew Adams
@ 2012-01-06 19:13 ` Masatake YAMATO
  2012-01-06 21:49   ` Masatake YAMATO
  2012-01-06 19:56 ` Richard Riley
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Masatake YAMATO @ 2012-01-06 19:13 UTC (permalink / raw)
  To: larsi; +Cc: emacs-devel

> 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



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 18:47 "Snippet" database Lars Magne Ingebrigtsen
  2012-01-06 19:08 ` Drew Adams
  2012-01-06 19:13 ` Masatake YAMATO
@ 2012-01-06 19:56 ` Richard Riley
  2012-01-06 20:16 ` Ted Zlatanov
  2012-01-07  3:06 ` John Wiegley
  4 siblings, 0 replies; 14+ messages in thread
From: Richard Riley @ 2012-01-06 19:56 UTC (permalink / raw)
  To: emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> 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...

Why not just use abbrev and define some nicer hotkeys? (FWIW, I never
got yasnippet working with org etc but never really tried that hard
either tbh).





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 18:47 "Snippet" database Lars Magne Ingebrigtsen
                   ` (2 preceding siblings ...)
  2012-01-06 19:56 ` Richard Riley
@ 2012-01-06 20:16 ` Ted Zlatanov
  2012-01-06 20:45   ` Eli Zaretskii
  2012-01-07  3:06 ` John Wiegley
  4 siblings, 1 reply; 14+ messages in thread
From: Ted Zlatanov @ 2012-01-06 20:16 UTC (permalink / raw)
  To: emacs-devel

On Fri, 06 Jan 2012 19:47:58 +0100 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> In my various guises I find myself sending out the same rote email
LMI> answer to many people.  "Thanks for the patch; applied" and stuff.  It
LMI> would be nice if one could just mark the region, ask Emacs to pull it
LMI> into a database of snippets, and then have a command that would insert
LMI> them again.

LMI> Surely something like this already exists in Emacs, but I just can't
LMI> seem to find it.  Probably looking for the wrong thing...

I usually put it in the kill ring, since with session.el I have the kill
ring persistent between Emacs sessions.  Normally I just keep doing
`M-y' (`yank-pop') repeatedly to find the old text, which in an odd way
is similar to what you're suggesting.  So maybe a `yank-select' command
to select from the kill ring would be useful to you, coupled with a way
to persist the kill ring if session.el is too heavy for you?

Ted




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 20:16 ` Ted Zlatanov
@ 2012-01-06 20:45   ` Eli Zaretskii
  2012-01-06 21:07     ` Ted Zlatanov
  2012-01-09  6:02     ` Drew Adams
  0 siblings, 2 replies; 14+ messages in thread
From: Eli Zaretskii @ 2012-01-06 20:45 UTC (permalink / raw)
  To: emacs-devel

> From: Ted Zlatanov <tzz@lifelogs.com>
> Date: Fri, 06 Jan 2012 15:16:24 -0500
> 
> So maybe a `yank-select' command to select from the kill ring would
> be useful to you

Possible today via the menu bar (Edit->Paste from Kill Menu).



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 20:45   ` Eli Zaretskii
@ 2012-01-06 21:07     ` Ted Zlatanov
  2012-01-06 21:10       ` Lars Magne Ingebrigtsen
  2012-01-09  6:02     ` Drew Adams
  1 sibling, 1 reply; 14+ messages in thread
From: Ted Zlatanov @ 2012-01-06 21:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Fri, 06 Jan 2012 22:45:38 +0200 Eli Zaretskii <eliz@gnu.org> wrote: 

>> From: Ted Zlatanov <tzz@lifelogs.com>
>> Date: Fri, 06 Jan 2012 15:16:24 -0500
>> 
>> So maybe a `yank-select' command to select from the kill ring would
>> be useful to you

EZ> Possible today via the menu bar (Edit->Paste from Kill Menu).

Cool!  I had never noticed that.  It would still be nice to have it as a
command with a popup buffer or something.

Ted



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 21:07     ` Ted Zlatanov
@ 2012-01-06 21:10       ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-01-06 21:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

>>> So maybe a `yank-select' command to select from the kill ring would
>>> be useful to you

That would be a very very long kill ring.  :-)

> Cool!  I had never noticed that.  It would still be nice to have it as a
> command with a popup buffer or something.

I think I'd like to do fancy completion on it.  I vaguely remember what
each canned response is supposed to say, so being able to hit
`H-r I absolutely refuse TAB' to get the snippet would be very nice.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 19:13 ` Masatake YAMATO
@ 2012-01-06 21:49   ` Masatake YAMATO
  2012-01-06 22:04     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Masatake YAMATO @ 2012-01-06 21:49 UTC (permalink / raw)
  To: larsi; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 21:49   ` Masatake YAMATO
@ 2012-01-06 22:04     ` Lars Magne Ingebrigtsen
  2012-01-06 22:17       ` Lennart Borgman
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-01-06 22:04 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: emacs-devel

Masatake YAMATO <yamato@redhat.com> writes:

> Here is the prototype of bookmark based snippet manager.

Thanks...  using fancy completion to find the snippet instead of listing
the snippets in a buffer would be more convenient, though, I think.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 22:04     ` Lars Magne Ingebrigtsen
@ 2012-01-06 22:17       ` Lennart Borgman
  2012-01-06 22:33         ` Tassilo Horn
  0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2012-01-06 22:17 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: Masatake YAMATO, emacs-devel

On Fri, Jan 6, 2012 at 23:04, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Masatake YAMATO <yamato@redhat.com> writes:
>
>> Here is the prototype of bookmark based snippet manager.
>
> Thanks...  using fancy completion to find the snippet instead of listing
> the snippets in a buffer would be more convenient, though, I think.

How about the snippet systems, like yasnippets? Can they perhaps be used?



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 22:17       ` Lennart Borgman
@ 2012-01-06 22:33         ` Tassilo Horn
  0 siblings, 0 replies; 14+ messages in thread
From: Tassilo Horn @ 2012-01-06 22:33 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Lars Magne Ingebrigtsen, Masatake YAMATO, emacs-devel

Lennart Borgman <lennart.borgman@gmail.com> writes:

> How about the snippet systems, like yasnippets? Can they perhaps be
> used?

I use that for about 3 years or so.  Since then, I haven't written "Bye,
Tassilo" and other such phrases anymore. :-)

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: "Snippet" database
  2012-01-06 18:47 "Snippet" database Lars Magne Ingebrigtsen
                   ` (3 preceding siblings ...)
  2012-01-06 20:16 ` Ted Zlatanov
@ 2012-01-07  3:06 ` John Wiegley
  4 siblings, 0 replies; 14+ messages in thread
From: John Wiegley @ 2012-01-07  3:06 UTC (permalink / raw)
  To: emacs-devel

>>>>> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> 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...

I copy the region, then run yas/new-snippet (from yasnippet, bound to C-c y
n).  I have many e-mail templates now.

John




^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: "Snippet" database
  2012-01-06 20:45   ` Eli Zaretskii
  2012-01-06 21:07     ` Ted Zlatanov
@ 2012-01-09  6:02     ` Drew Adams
  1 sibling, 0 replies; 14+ messages in thread
From: Drew Adams @ 2012-01-09  6:02 UTC (permalink / raw)
  To: emacs-devel

> > So maybe a `yank-select' command to select from the kill ring would
> > be useful to you
> 
> Possible today via the menu bar (Edit->Paste from Kill Menu).


Using completion against the `kill-ring' is a whole lot handier than
picking a kill from a menu.

FWIW -

For "snippet" stuff it is handy to have a selection ring that is
separate from the kill ring.  The kill ring is volatile, and many of
its entries are typically not something you necessarily want to yank -
there can be a lot of noise.

A less volatile selection is the secondary selection.  Library
`second-sel.el' gives you a ring for this, `secondary-selection-ring',
which you can use the same way as the `kill-ring'.  Its entries can be
more appropriate for snippets, since a typical use of killing text
does not have snippets in mind.

In any case, it's also good to be able to copy or move a selection
from one ring to the other - e.g. to save a kill as a snippet.

Library `browse-kill-ring+.el' lets you browse either selection ring
(kills or secondary selections), yank entries from it, and copy or
move selections from one ring to the other.  You can create other
selection rings to browse, and you can of course persist a ring using
savehist or whatever (e.g., a "database of snippets").

With these libraries (by default), if `M-y' follows a yank command, it
acts normally.  If it follows a yank-secondary command it acts
similarly but using the `secondary-selection-ring' instead of the
`kill-ring'.  Otherwise (`M-y' at top level), it browses the current
ring or, if in a buffer browsing a ring, it browses the other ring.

In Icicles (by default), `M-y' acts similarly.  But instead of
browsing selections, a top-level `M-y' yanks a selection using
completion, from the `kill-ring' or (with prefix arg) from the
`secondary-selection-ring'.

During this completion you can hit a key to:

* Copy a selection to the other ring
* Delete a selection from the current ring
* Sort the selections in various ways for easier access (no dups)

http://www.emacswiki.org/emacs/SecondarySelection#secondary-sel.el
http://www.emacswiki.org/emacs/BrowseKillRing




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-01-09  6:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-06 18:47 "Snippet" database Lars Magne Ingebrigtsen
2012-01-06 19:08 ` Drew Adams
2012-01-06 19:13 ` Masatake YAMATO
2012-01-06 21:49   ` Masatake YAMATO
2012-01-06 22:04     ` Lars Magne Ingebrigtsen
2012-01-06 22:17       ` Lennart Borgman
2012-01-06 22:33         ` Tassilo Horn
2012-01-06 19:56 ` Richard Riley
2012-01-06 20:16 ` Ted Zlatanov
2012-01-06 20:45   ` Eli Zaretskii
2012-01-06 21:07     ` Ted Zlatanov
2012-01-06 21:10       ` Lars Magne Ingebrigtsen
2012-01-09  6:02     ` Drew Adams
2012-01-07  3:06 ` John Wiegley

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).