[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: Use with yasnippets?
From: |
Bernt Hansen |
Subject: |
[Orgmode] Re: Use with yasnippets? |
Date: |
Thu, 23 Apr 2009 21:43:31 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Mark Elston <address@hidden> writes:
> I know someone mentioned yasnippets earlier this month but I can't
> find it. And I don't know if it answers my question or not anyway.
>
> I have a number of *very* similar entries in an org file. I teach
> a number of classes and I would like to set up a yasnippet to create
> entries (actually a small tree of entries) for each class. The
> snippet would have several tab-stops so I can enter the class name
> and lesson number once and have it appear several times in the
> created entries.
>
> However, when trying to actually expand this snippet and navigate
> between the tab-stops, the tab key (naturally) closes up the tree
> it just created and fails to let me enter the second (or subsequent)
> placeholders.
>
> Is there any way of using the flexibility of yasnippets in org mode?
Hi Mark,
It mostly works for me.
I just made the following test snippet:
,----[ test ]
| #name : #+test
| # --
| * $1
| First thing
| ** $2
| Second thing
| *** $3
| Third Thing
| *** $4
| Fourth thing
| ** $5
| Fifth thing
| Done.
| $0
`----
and typing 'testTAB' and repeatedly hitting TAB and entering data gave
me this output
,----
| * one
| First thing
| ** two
| Second thing
| *** three
| Third Thing
| *** four
| Fourth thing
| ** five
| Fifth thing
| Done.
| six
`----
I have the following setup for yasnippets - it's not perfect (because it
messes up forward TAB in tables) but it is working pretty well -- good
enough that I don't want to go back to not using yasnippets :)
--8<---------------cut here---------------start------------->8---
(add-hook 'org-mode-hook
(lambda ()
;; yasnippet
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(define-key yas/keymap [tab] 'yas/next-field-group)
(flyspell-mode 1)))
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet/snippets")
--8<---------------cut here---------------end--------------->8---
HTH,
Bernt