yasnippet in org-mode

333 views
Skip to first unread message

Jeff

unread,
Jul 31, 2008, 3:42:30 PM7/31/08
to smart-snippet and YASnippet
Hi all--

Has anyone had success using yasnippet in org-mode?

When I'm in org-mode yasnippet is definitely running, and "yas"
displays in my mode-line.

However, when I do C-h k <tab>, the output reads:

<tab> runs the command org-cycle
which is an interactive compiled Lisp function in `/Users/jstautz/
Dropbox/.emacs.d/org.elc'.
It is bound to <tab>, <menu-bar> <Tbl> <Next Field>, <menu-bar> <Org>
<Show/Hide> <Cycle Visibility>.
(org-cycle &optional arg)

Has anyone found any workarounds for this?

--Jeff

Zhang Chiyuan

unread,
Aug 1, 2008, 1:40:06 AM8/1/08
to smart-...@googlegroups.com
This should work:

(add-hook 'org-mode-hook
'(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])))

BTW, I've also added this to the FAQ:
http://pluskid.lifegoo.com/upload/project/yasnippet/doc/faq.html

--
pluskid

Jeff

unread,
Aug 1, 2008, 1:03:20 PM8/1/08
to smart-snippet and YASnippet
Brilliant! Works great. Thanks!
--Jeff

Zhang Chiyuan

unread,
Oct 20, 2008, 1:58:44 AM10/20/08
to Eric Griffis, smart-...@googlegroups.com
Hi! I see, it seems that org-mode is also taking over the [tab] for
next-field navigation. You may try this:

(add-hook 'org-mode-hook
(lambda ()
(define-key yas/keymap [tab] 'yas/next-field-group))

Hope this can solve your problem.

On Mon, Oct 20, 2008 at 1:33 PM, Eric Griffis <ded...@gmail.com> wrote:
> Hello,
>
> Thanks for the tip! I can now successfully trigger expansion, but
> pressing [tab] does not advance through fields. Here's my C-h k while
> inside a field:
>
> <tab> runs the command yas/expand
> which is an interactive Lisp function in `yasnippet.el'.
> It is bound to <tab>.
> (yas/expand)
>
> Expand a snippet.
>
> If I remove the add-hook and manually initiate yas/expand, C-h k in
> the field reports <tab> is bound to org-cycle.
>
> Eric


>
>
> On Jul 31, 10:40 pm, "Zhang Chiyuan" <plus...@gmail.com> wrote:

>> This should work:
>>
>> (add-hook 'org-mode-hook
>> '(lambda ()
>> (make-variable-buffer-local 'yas/trigger-key)
>> (setq yas/trigger-key [tab])))
>>
>> BTW, I've also added this to the FAQ:http://pluskid.lifegoo.com/upload/project/yasnippet/doc/faq.html
>>
>>
>>
>> On Fri, Aug 1, 2008 at 3:42 AM, Jeff <jeff.sta...@gmail.com> wrote:
>>
>> > Hi all--
>>
>> > Has anyone had success using yasnippet inorg-mode?
>>

>> > When I'm inorg-modeyasnippet is definitely running, and "yas"


>> > displays in my mode-line.
>>
>> > However, when I do C-h k <tab>, the output reads:
>>
>> > <tab> runs the command org-cycle
>> > which is an interactive compiled Lisp function in `/Users/jstautz/
>> > Dropbox/.emacs.d/org.elc'.
>> > It is bound to <tab>, <menu-bar> <Tbl> <Next Field>, <menu-bar> <Org>
>> > <Show/Hide> <Cycle Visibility>.
>> > (org-cycle &optional arg)
>>
>> > Has anyone found any workarounds for this?
>>
>> > --Jeff
>>
>> --
>> pluskid

--
pluskid

ded...@gmail.com

unread,
Oct 20, 2008, 3:26:41 AM10/20/08
to Zhang Chiyuan, smart-...@googlegroups.com
It works perfectly. Thanks for the help, and for responding so quickly!

Eric



On Oct 19, 2008 10:58pm, Zhang Chiyuan <plu...@gmail.com> wrote:
> Hi! I see, it seems that org-mode is also taking over the [tab] for
>
> next-field navigation. You may try this:
>
>
>
> (add-hook 'org-mode-hook
>
>  (lambda ()
>
> (define-key yas/keymap [tab] 'yas/next-field-group))
>
>
>
> Hope this can solve your problem.
>
>
>
> On Mon, Oct 20, 2008 at 1:33 PM, Eric Griffis wrote:
>
> > Hello,
>
> >
>
> > Thanks for the tip! I can now successfully trigger expansion, but
>
> > pressing [tab] does not advance through fields. Here's my C-h k while
>
> > inside a field:
>
> >
>
> > runs the command yas/expand
>
> >  which is an interactive Lisp function in `yasnippet.el'.
>
> > It is bound to .

>
> > (yas/expand)
>
> >
>
> > Expand a snippet.
>
> >
>
> > If I remove the add-hook and manually initiate yas/expand, C-h k in
>
> > the field reports is bound to org-cycle.

>
> >
>
> > Eric
>
> >
>
> >
>
> > On Jul 31, 10:40 pm, "Zhang Chiyuan" wrote:
>
> >> This should work:
>
> >>
>
> >> (add-hook 'org-mode-hook
>
> >>           '(lambda ()
>
> >>              (make-variable-buffer-local 'yas/trigger-key)
>
> >>              (setq yas/trigger-key [tab])))
>
> >>
>
> >> BTW, I've also added this to the FAQ:http://pluskid.lifegoo.com/upload/project/yasnippet/doc/faq.html
>
> >>
>
> >>
>
> >>
>
> >> On Fri, Aug 1, 2008 at 3:42 AM, Jeff wrote:
>
> >>
>
> >> > Hi all--
>
> >>
>
> >> > Has anyone had success using yasnippet inorg-mode?
>
> >>
>
> >> > When I'm inorg-modeyasnippet is definitely running, and "yas"
>
> >> > displays in my mode-line.
>
> >>
>
> >> > However, when I do C-h k , the output reads:

>
> >>
>
> >> > runs the command org-cycle
>
> >> >  which is an interactive compiled Lisp function in `/Users/jstautz/
>
> >> > Dropbox/.emacs.d/org.elc'.
>
> >> > It is bound to , ,

Lowyn

unread,
Nov 10, 2008, 11:06:52 AM11/10/08
to smart-snippet and YASnippet


On 20 oct, 06:58, "Zhang Chiyuan" <plus...@gmail.com> wrote:
> Hi! I see, it seems that org-mode is also taking over the [tab] for
> next-field navigation. You may try this:
>
> (add-hook 'org-mode-hook
>   (lambda ()
> (define-key yas/keymap [tab] 'yas/next-field-group))
>
> Hope this can solve your problem.

Hello.

Is there a way to get S-iso-lefttab also working under org-mode ?

Thanks for any advice.
Message has been deleted

Zhang Chiyuan

unread,
Nov 10, 2008, 11:15:58 AM11/10/08
to smart-...@googlegroups.com
Hi,

I think it might be similar:

(add-hook 'org-mode-hook
(lambda ()
(define-key yas/keymap [tab] 'yas/next-field-group)

(define-key yas/keymap (kbd "S-iso-lefttab") 'yas/prev-field-group))

--
pluskid

Lowyn

unread,
Nov 10, 2008, 11:40:37 AM11/10/08
to smart-snippet and YASnippet
That's what I thought but I got the error "S- must prefix a single
character, not iso-lefttab".

Lowyn

unread,
Nov 10, 2008, 12:03:57 PM11/10/08
to smart-snippet and YASnippet
Well forget what I say, it works without defining anything. Sorry for
the noise.

Thank you for your answer, anyway.

Zhang Chiyuan

unread,
Nov 10, 2008, 10:56:34 PM11/10/08
to smart-...@googlegroups.com
Or maybe it would be (kbd "<S-iso-tab>")

On Tue, Nov 11, 2008 at 12:40 AM, Lowyn <lowyn.m...@gmail.com> wrote:
>
> That's what I thought but I got the error "S- must prefix a single
> character, not iso-lefttab".
> >
>

--
pluskid

Ian

unread,
Nov 24, 2008, 5:29:29 AM11/24/08
to smart-snippet and YASnippet
>
> (add-hook 'org-mode-hook
>   (lambda ()
> (define-key yas/keymap [tab] 'yas/next-field-group))
>
> Hope this can solve your problem.
>
>
I am also having problems with org mode. If I run emacs -Q and then
evaluate the following:

(load "~/.emacs-lisp/plugins/yasnippet.el")
(yas/initialize)
(yas/load-directory "~/.emacs-lisp/snippets")
(add-to-list 'load-path "~/.emacs-lisp/org")
(require 'org)

(add-hook 'org-mode-hook
'(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])))

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

Now I open an org file and try to use tab to evaluate a snippet it
doesn't work. However it works correctly if I am editing a file in
text mode. Here's what C-h k shows about the Tab key in org mode:

<tab> runs the command yas/expand, which is an interactive Lisp
function in `yasnippet.el'.

It is bound to TAB, <tab>.

(yas/expand)

Expand a snippet.

I have tried this with Emacs 22 in Ubuntu and also the Emacs snapshot:
GNU Emacs 23.0.60.1 (i486-pc-linux-gnu, GTK+ Version 2.14.3)
of 2008-10-13 on rothera, modified by Debian

Ian.



Zhang Chiyuan

unread,
Nov 24, 2008, 8:55:02 AM11/24/08
to smart-...@googlegroups.com
Make sure you have snippets defined for org-mode. If you want to use
the snippets from text-mode in org-mode, you can make an empty directory
named org-mode in the text-mode directory where you put your text mode
snippets.
--
pluskid

Ian

unread,
Nov 24, 2008, 9:44:12 AM11/24/08
to smart-snippet and YASnippet


On Nov 24, 1:55 pm, "Zhang Chiyuan" <plus...@gmail.com> wrote:
> Make sure you have snippets defined for org-mode. If you want to use
> the snippets from text-mode in org-mode, you can make an empty directory
> named org-mode in the text-mode directory where you put your text mode
> snippets.
>
>
Thanks that worked.

Ian.
Reply all
Reply to author
Forward
0 new messages