* Use with yasnippets?
@ 2009-04-23 23:11 Mark Elston
2009-04-24 1:43 ` Bernt Hansen
0 siblings, 1 reply; 3+ messages in thread
From: Mark Elston @ 2009-04-23 23:11 UTC (permalink / raw
To: org-mode emacs-orgmode
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?
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use with yasnippets?
2009-04-23 23:11 Use with yasnippets? Mark Elston
@ 2009-04-24 1:43 ` Bernt Hansen
2009-04-24 1:48 ` Mark Elston
0 siblings, 1 reply; 3+ messages in thread
From: Bernt Hansen @ 2009-04-24 1:43 UTC (permalink / raw
To: Mark Elston; +Cc: org-mode emacs-orgmode
Mark Elston <m_elston@comcast.net> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use with yasnippets?
2009-04-24 1:43 ` Bernt Hansen
@ 2009-04-24 1:48 ` Mark Elston
0 siblings, 0 replies; 3+ messages in thread
From: Mark Elston @ 2009-04-24 1:48 UTC (permalink / raw
To: Bernt Hansen; +Cc: org-mode emacs-orgmode
Bernt,
Thanks. That was it. I knew there must be a mode-hook or
some such I could take advantage of ant that was what I was
missing.
Mark
Bernt Hansen wrote:
> Mark Elston <m_elston@comcast.net> 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
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-24 1:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-23 23:11 Use with yasnippets? Mark Elston
2009-04-24 1:43 ` Bernt Hansen
2009-04-24 1:48 ` Mark Elston
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.