emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Using yasnippet with org Mode
@ 2008-11-23 19:23 Ian Barton
  2008-11-23 21:11 ` Eric Schulte
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Ian Barton @ 2008-11-23 19:23 UTC (permalink / raw)
  To: emacs-orgmode Org-Mode

Someone on the list mentioned yasnippet a while ago. I have been trying 
it out and I like it. However, I can't get it to play nicely with org 
mode. I have read various fixes, but none seem to work for me. To 
summarize what I have done:

In my .emacs:

(require 'org-install)

;; Yasnippet
(add-to-list 'load-path "~/.emacs-lisp/plugins")
(require 'yasnippet)
(add-to-list 'yas/extra-mode-hooks
              'python-mode-hook)
(yas/initialize)
(yas/load-directory "~/.emacs-lisp/snippets/")

;; Make Yasnippet play nicely with org mode.
(add-hook 'org-mode-hook
'(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])))

When I run C-h k I get:

<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 can see yas in my status line when I open an org file and using tab 
with yasnippet works fine in other text mode files. I think that I am 
probably missing something obvious, as other people can get it to work.

Ian.

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

* Re: Using yasnippet with org Mode
  2008-11-23 19:23 Using yasnippet with org Mode Ian Barton
@ 2008-11-23 21:11 ` Eric Schulte
  2008-11-23 21:17   ` Tassilo Horn
  2008-11-24  0:45 ` Oliver Charles
  2009-09-19  5:06 ` Using yasnippet with org Mode (C-i works TAB doesn't) Jeff Kowalczyk
  2 siblings, 1 reply; 18+ messages in thread
From: Eric Schulte @ 2008-11-23 21:11 UTC (permalink / raw)
  To: Ian Barton; +Cc: emacs-orgmode Org-Mode

Ian Barton <lists@manor-farm.org> writes:

> ;; Make Yasnippet play nicely with org mode.
> (add-hook 'org-mode-hook
> '(lambda ()
> (make-variable-buffer-local 'yas/trigger-key)
> (setq yas/trigger-key [tab])))
>

I think maybe your lambda should not be quoted, try

;; Make Yasnippet play nicely with org mode.
(add-hook 'org-mode-hook
	  (lambda ()
	    (make-variable-buffer-local 'yas/trigger-key)
	    (setq yas/trigger-key [tab])))

-- Eric

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

* Re: Using yasnippet with org Mode
  2008-11-23 21:11 ` Eric Schulte
@ 2008-11-23 21:17   ` Tassilo Horn
  2008-11-23 22:43     ` Eric Schulte
  0 siblings, 1 reply; 18+ messages in thread
From: Tassilo Horn @ 2008-11-23 21:17 UTC (permalink / raw)
  To: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

Hi Eric,

> I think maybe your lambda should not be quoted, try

Since lambda evaluates to itself, that doesn't make any difference.

,----
| ELISP> (lambda () nil)
| (lambda nil nil)
| ELISP> (quote (lambda () nil))
| (lambda nil nil)
`----

I suspect yasnippet doesn't play nice with org because both are
passionate key hijackers.  I'd try to bind yas/expand to some other key,
maybe M-TAB in org-mode.

Bye,
Tassilo

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

* Re: Re: Using yasnippet with org Mode
  2008-11-23 21:17   ` Tassilo Horn
@ 2008-11-23 22:43     ` Eric Schulte
  2008-11-24  9:34       ` Ian Barton
                         ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Eric Schulte @ 2008-11-23 22:43 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode

Tassilo Horn <tassilo@member.fsf.org> writes:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
> Hi Eric,
>
>> I think maybe your lambda should not be quoted, try
>
> Since lambda evaluates to itself, that doesn't make any difference.
>

Thanks Tassilo, I didn't realize that was the case

As for using yasnippets with tab, the following successfully binds tab
to yas/expand when I start emacs with

  emacs -Q  (skips loading customization)

and then evaluate the following elisp to load yasnippets and org-mode

(load "~/emacs/elisp/util/yasnippet.el")
(yas/initialize)
(yas/load-directory "~/emacs/snippets")
(add-to-list 'load-path "~/emacs/org")
(require 'org)
(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)))

This works for me using a fairly recent Emacs 23 from cvs.

Hope this helps -- Eric

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

* Re: Using yasnippet with org Mode
  2008-11-23 19:23 Using yasnippet with org Mode Ian Barton
  2008-11-23 21:11 ` Eric Schulte
@ 2008-11-24  0:45 ` Oliver Charles
  2008-11-24 15:40   ` Eric Schulte
  2009-09-19  5:06 ` Using yasnippet with org Mode (C-i works TAB doesn't) Jeff Kowalczyk
  2 siblings, 1 reply; 18+ messages in thread
From: Oliver Charles @ 2008-11-24  0:45 UTC (permalink / raw)
  To: Ian Barton; +Cc: emacs-orgmode Org-Mode

Hi, sorry to be a little off topic but...

I'm curious to hear what snippets people are using with org-mode.
Anyone fancing sharing?

- OLlie

On Sun, Nov 23, 2008 at 7:23 PM, Ian Barton <lists@manor-farm.org> wrote:
> Someone on the list mentioned yasnippet a while ago. I have been trying it
> out and I like it. However, I can't get it to play nicely with org mode. I
> have read various fixes, but none seem to work for me. To summarize what I
> have done:
>
> In my .emacs:
>
> (require 'org-install)
>
> ;; Yasnippet
> (add-to-list 'load-path "~/.emacs-lisp/plugins")
> (require 'yasnippet)
> (add-to-list 'yas/extra-mode-hooks
>             'python-mode-hook)
> (yas/initialize)
> (yas/load-directory "~/.emacs-lisp/snippets/")
>
> ;; Make Yasnippet play nicely with org mode.
> (add-hook 'org-mode-hook
> '(lambda ()
> (make-variable-buffer-local 'yas/trigger-key)
> (setq yas/trigger-key [tab])))
>
> When I run C-h k I get:
>
> <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 can see yas in my status line when I open an org file and using tab with
> yasnippet works fine in other text mode files. I think that I am probably
> missing something obvious, as other people can get it to work.
>
> Ian.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

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

* Re: Re: Using yasnippet with org Mode
  2008-11-23 22:43     ` Eric Schulte
@ 2008-11-24  9:34       ` Ian Barton
  2008-11-24 23:51         ` Sebastian Rose
  2008-11-24 14:46       ` Re: Using yasnippet with org Mode [Solved] Ian Barton
  2008-11-24 15:38       ` Re: Using yasnippet with org Mode Eric Schulte
  2 siblings, 1 reply; 18+ messages in thread
From: Ian Barton @ 2008-11-24  9:34 UTC (permalink / raw)
  To: emacs-orgmode

> As for using yasnippets with tab, the following successfully binds tab
> to yas/expand when I start emacs with
> 
>   emacs -Q  (skips loading customization)
> 
> and then evaluate the following elisp to load yasnippets and org-mode
> 
> (load "~/emacs/elisp/util/yasnippet.el")
> (yas/initialize)
> (yas/load-directory "~/emacs/snippets")
> (add-to-list 'load-path "~/emacs/org")
> (require 'org)
> (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)))
> 
> This works for me using a fairly recent Emacs 23 from cvs.
> 

Thanks, I have tried that, but it didn't work for me:) I am using Emacs 
22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
  of 2008-09-05 on vernadsky, modified by Ubuntu. I have also tried 
binding Yasnippet to the F1 key, which isn't used by anything else. 
Whilst this works in text mode, it doesn't in org mode.

I'll ask in the Yasnippet list and see if they can suggest anything.

Ian.

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

* Re: Re: Using yasnippet with org Mode [Solved]
  2008-11-23 22:43     ` Eric Schulte
  2008-11-24  9:34       ` Ian Barton
@ 2008-11-24 14:46       ` Ian Barton
  2008-11-24 15:38       ` Re: Using yasnippet with org Mode Eric Schulte
  2 siblings, 0 replies; 18+ messages in thread
From: Ian Barton @ 2008-11-24 14:46 UTC (permalink / raw)
  To: emacs-orgmode

> As for using yasnippets with tab, the following successfully binds tab
> to yas/expand when I start emacs with
> 
>   emacs -Q  (skips loading customization)
> 
> and then evaluate the following elisp to load yasnippets and org-mode
> 
> (load "~/emacs/elisp/util/yasnippet.el")
> (yas/initialize)
> (yas/load-directory "~/emacs/snippets")
> (add-to-list 'load-path "~/emacs/org")
> (require 'org)
> (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)))
> 
> This works for me using a fairly recent Emacs 23 from cvs.
> 

The answer is:

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

Now working perfectly:)

Ian.

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

* Re: Re: Using yasnippet with org Mode
  2008-11-23 22:43     ` Eric Schulte
  2008-11-24  9:34       ` Ian Barton
  2008-11-24 14:46       ` Re: Using yasnippet with org Mode [Solved] Ian Barton
@ 2008-11-24 15:38       ` Eric Schulte
  2 siblings, 0 replies; 18+ messages in thread
From: Eric Schulte @ 2008-11-24 15:38 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode

A solution for using yasnippets in org-mode (from the yasnippets mailing
list)

  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.

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

* Re: Using yasnippet with org Mode
  2008-11-24  0:45 ` Oliver Charles
@ 2008-11-24 15:40   ` Eric Schulte
  2008-11-25 15:44     ` Org mode snippets WAS: " Jonathan Arkell
  0 siblings, 1 reply; 18+ messages in thread
From: Eric Schulte @ 2008-11-24 15:40 UTC (permalink / raw)
  To: Oliver Charles; +Cc: emacs-orgmode Org-Mode

"Oliver Charles" <oliver.g.charles@googlemail.com> writes:

> Hi, sorry to be a little off topic but...
>
> I'm curious to hear what snippets people are using with org-mode.
> Anyone fancing sharing?
>

The only org-mode specific snippet I use often is the following (for
creating blocks in org files)

,----[block]
| #name : #+begin_...#+end_
| # --
| #+begin_$1 $2
| $0
| #+end_$1
`----

I'd be interested to hear others -- Eric

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

* Re: Re: Using yasnippet with org Mode
  2008-11-24  9:34       ` Ian Barton
@ 2008-11-24 23:51         ` Sebastian Rose
  0 siblings, 0 replies; 18+ messages in thread
From: Sebastian Rose @ 2008-11-24 23:51 UTC (permalink / raw)
  To: emacs-orgmode

Ian,


this is my yasnippets setup:


.emacs
=> --->8----------------------------->8----------------------------->8---

(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "/home/sebastian/emacs/snippets/")

;; I use the WIN key for my own bindings, since I didn't use Windows for
;; ages, and I don't plan to :-)
;; H-y is convenient on german keyboard (like M-z on english/US
;; keyboard):

(defun sr-yas-in-org ()
  "Define H-y as yas/expand in org"
  (define-key org-mode-map [(hyper ?y)] 'yas/expand))

(add-hook 'org-mode-hook 'sr-yas-in-org)

<= ---8<-----------------------------8<-----------------------------8<---



Setup of the snippets tree beneath /home/sebastian/emacs/snippets/:

.
`-- fundamental-mode
    |-- cc-mode
    |   |-- c++-mode
    |   `-- c-mode
    |-- css-mode
    |-- html-mode
    |-- java-mode
    |-- message-mode
    |-- org-mode
    |-- perl-mode
    |   `-- cperl-mode
    |-- php-mode
    `-- picture-mode


As you can see, all modes inherit the snippets from fundamental
mode.




Example:

There's a `box' snippet in fundamental-mode which I may use in all
modes. It lives in a file named `box' in fundamental-mode and produces
an output like this:

      ,---------------.
      ! this is a box |
      `---------------´

Since I have _no_ file named `box' in `org-mode', expanding "box" in an
Org-file looks just the same:

      ,----------------------.
      ! This is a box in org |
      `----------------------´


For some modes, I overwrite it, simply by adding a file name `box' in
the appropriate subdirectory. This is the result of expanding
`php-mode/box' in a Php-file:

// ------------- //
// This is a box //
// ------------- //


... and in `picture-mode/box':

: +-----------------------+
: | A box in picture-mode |
: +-----------------------+


The former is what used, if I expand the `org-mode/ditaa' snippet in an
org-file, and press C-c '


#+begin_ditaa asdf.png -o
: +-----------------------+
: | A box in picture-mode |
: +-----------------------+
#+end_ditaa




In picture-mode, I have several boxes. I may choose one using the arrow
keys, if all their filenames start  with 'box':

picture-mode/box:
 +------------------------+
 | A box in pictqure-mode |
 +------------------------+

picture-mode/box.stippled-rounded:
 /---------\
 | Rounded |
 \---------/

picture-mode/box.stippled:
 +--------=-+
 | Stippled |
 +----------+

picture-mode/box.stippled-rounded:
 /--------------------=-\
 | Rounded and stippled |
 \----------------------/




box:

=> --->8----------------------------->8----------------------------->8---
#name : ! box |
# --
      ,${1:$(make-string (string-width text) ?\-)}--.
      ! ${1:SubTitle} |
      \`${1:$(make-string (string-width text) ?\-)}--´
$0
<= ---8<-----------------------------8<-----------------------------8<---



picture-mode/box (you have to draw the closing `|' yourself):

=> --->8----------------------------->8----------------------------->8---
#name : | straight |
# --
+${1:$(make-string (string-width text) ?\-)}--+
| ${1:Entity} |$0
+${1:$(make-string (string-width text) ?\-)}--+
<= ---8<-----------------------------8<-----------------------------8<---



picture-mode/box.rounded:

=> --->8----------------------------->8----------------------------->8---
#name : | rounded |
# --
/${1:$(make-string (string-width text) ?\-)}--\\
| ${1:Entity} |$0
\\${1:$(make-string (string-width text) ?\-)}--/
<= ---8<-----------------------------8<-----------------------------8<---





One of my most used ones is this here in `php-mode/debug':

=> --->8----------------------------->8----------------------------->8---
#contributor : Sebastian Rose <sebastian_rose@gmx.de>
#name : echo "<pre>"; print_r( ...
# --
echo "<pre><b>\\\$$1:</b><br />"; print_r(\$$1); echo "<br />".__FILE__.", line ".__LINE__."</pre>";$0 exit;
<= ---8<-----------------------------8<-----------------------------8<---




You get the idea...


Regards, 


   Sebastian


Ian Barton <lists@manor-farm.org> writes:
>> As for using yasnippets with tab, the following successfully binds tab
>> to yas/expand when I start emacs with
>>
>>   emacs -Q  (skips loading customization)
>>
>> and then evaluate the following elisp to load yasnippets and org-mode
>>
>> (load "~/emacs/elisp/util/yasnippet.el")
>> (yas/initialize)
>> (yas/load-directory "~/emacs/snippets")
>> (add-to-list 'load-path "~/emacs/org")
>> (require 'org)
>> (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)))
>>
>> This works for me using a fairly recent Emacs 23 from cvs.
>>
>
> Thanks, I have tried that, but it didn't work for me:) I am using Emacs 22.2.1
> (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
>  of 2008-09-05 on vernadsky, modified by Ubuntu. I have also tried binding
> Yasnippet to the F1 key, which isn't used by anything else. Whilst this works in
> text mode, it doesn't in org mode.
>
> I'll ask in the Yasnippet list and see if they can suggest anything.
>
> Ian.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover

Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http:  www.emma-stil.de

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

* Org mode snippets WAS: Using yasnippet with org Mode
  2008-11-24 15:40   ` Eric Schulte
@ 2008-11-25 15:44     ` Jonathan Arkell
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Arkell @ 2008-11-25 15:44 UTC (permalink / raw)
  To: Eric Schulte, Oliver Charles; +Cc: emacs-orgmode Org-Mode

I make extensive use of yasnippets with org.

I usually have different page types (Person, project, etc) and for each page type I usually have a snippet.  Some of my snippets are specifically for my needs, but some of them are more general:

#name : Properties Folded
#contributor : Jonathan Arkell <jonnay@jonnay.net>
# --
  :PROPERTIES:
  :VISIBILITY:folded:
  :END:

#name : Personal Project
#contributor : Jonathan Arkell <jonnay@jonnay.net>
# --
* $1							  :project:personal:
** Why?
    - $2
** Outcome
    $3
** Brainstorming
*** $4
*** Who?
*** What?
*** When?
*** Where?
*** Why?
*** How?
** Plan
*** Milestones
**** $6

#name : Meeting
#contributor : Jonathan Arkell <jonnay@jonnay.net>
# --
**** Attendees
     - $1
**** General Notes
     - $2
**** Generated Tasks
**** Open Questions



-----Original Message-----
From: emacs-orgmode-bounces+jonathana=criticalmass.com@gnu.org [mailto:emacs-orgmode-bounces+jonathana=criticalmass.com@gnu.org] On Behalf Of Eric Schulte
Sent: Monday, November 24, 2008 8:40 AM
To: Oliver Charles
Cc: emacs-orgmode Org-Mode
Subject: Re: [Orgmode] Using yasnippet with org Mode

"Oliver Charles" <oliver.g.charles@googlemail.com> writes:

> Hi, sorry to be a little off topic but...
>
> I'm curious to hear what snippets people are using with org-mode.
> Anyone fancing sharing?
>

The only org-mode specific snippet I use often is the following (for
creating blocks in org files)

,----[block]
| #name : #+begin_...#+end_
| # --
| #+begin_$1 $2
| $0
| #+end_$1
`----

I'd be interested to hear others -- Eric


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

The information contained in this message is confidential. It is intended to be read only by the individual or entity named above or their designee. If the reader of this message is not the intended recipient, you are hereby notified that any distribution of this message, in any form, is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete or destroy any copy of this message.

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

* Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2008-11-23 19:23 Using yasnippet with org Mode Ian Barton
  2008-11-23 21:11 ` Eric Schulte
  2008-11-24  0:45 ` Oliver Charles
@ 2009-09-19  5:06 ` Jeff Kowalczyk
  2009-09-19 13:03   ` Nicolas Goaziou
  2009-09-19 13:46   ` Eric Schulte
  2 siblings, 2 replies; 18+ messages in thread
From: Jeff Kowalczyk @ 2009-09-19  5:06 UTC (permalink / raw)
  To: emacs-orgmode

With Emacs 23.1, org git master, and yasnippet svn trunk, I have the problem
that the TAB key does not expand snippets, but C-i does. I'm using the Org
Manual's recommended configuration to address the conflict, see init.el lines
matching org|yas below:


(load-file "~/.emacs.d/vendor/yasnippet/yasnippet.el")
(yas/initialize)
(yas/load-directory "~/.emacs.d/vendor/yasnippet/snippets")
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(setq org-log-done 'time)
(setq org-special-ctrl-k t)
(org-remember-insinuate)
(setq org-directory "~/org/")
(setq org-default-notes-file (concat org-directory "/notes.org"))
(define-key global-map "\C-cr" 'org-remember)
(setq org-clock-into-drawer t)
(setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree))
(add-hook 'org-mode-hook
  (lambda ()
  (org-set-local 'yas/trigger-key [tab])
  (define-key yas/keymap [tab] 'yas/next-field-group)))


I normally have ido enabled, but I disabled it with no change in the behavior.
Thanks for any suggestions.

Jeff

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

* Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2009-09-19  5:06 ` Using yasnippet with org Mode (C-i works TAB doesn't) Jeff Kowalczyk
@ 2009-09-19 13:03   ` Nicolas Goaziou
  2009-09-20 14:16     ` Eric Schulte
  2009-09-19 13:46   ` Eric Schulte
  1 sibling, 1 reply; 18+ messages in thread
From: Nicolas Goaziou @ 2009-09-19 13:03 UTC (permalink / raw)
  To: Jeff Kowalczyk; +Cc: emacs-orgmode

Jeff Kowalczyk <jtk@yahoo.com> writes:

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

According to the yasnippet FAQ (or is it on its forum), it should be

(add-hook 'org-mode-hook
          #'(lambda ()
              (setq yas/fallback-behavior
                    `(apply ,(lookup-key org-mode-map [tab])))
              (local-set-key [tab] 'yas/expand)))

Anyway, there is one major problem left, it doesn't work with
org-indent-mode as, when you press TAB to get to the next field of a
snippet, you are sent to the first headline in the org file.

I have yet to find a workaround about that.

Regards,

-- 
Nicolas Goaziou

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

* Re: Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2009-09-19  5:06 ` Using yasnippet with org Mode (C-i works TAB doesn't) Jeff Kowalczyk
  2009-09-19 13:03   ` Nicolas Goaziou
@ 2009-09-19 13:46   ` Eric Schulte
  1 sibling, 0 replies; 18+ messages in thread
From: Eric Schulte @ 2009-09-19 13:46 UTC (permalink / raw)
  To: Jeff Kowalczyk; +Cc: emacs-orgmode

Hmm,

The following works for me

--8<---------------cut here---------------start------------->8---
(add-hook 'org-mode-hook
          (lambda ()
	    (make-variable-buffer-local 'yas/trigger-key)
	    (setq yas/trigger-key [tab])
	    (define-key yas/keymap [tab] 'yas/next-field-group)))
--8<---------------cut here---------------end--------------->8---

but what you already have looks more like the suggestion in the FAQ at
http://orgmode.org/worg/org-faq.php#YASnippet, so I wouldn't be
surprised if my setup doesn't work for you either...

I'm also using the org git master, and emacs 23 git master, so maybe the
problem is related to a recent change in the yasnippet repo?

Best -- Eric

Jeff Kowalczyk <jtk@yahoo.com> writes:

> With Emacs 23.1, org git master, and yasnippet svn trunk, I have the problem
> that the TAB key does not expand snippets, but C-i does. I'm using the Org
> Manual's recommended configuration to address the conflict, see init.el lines
> matching org|yas below:
>
>
> (load-file "~/.emacs.d/vendor/yasnippet/yasnippet.el")
> (yas/initialize)
> (yas/load-directory "~/.emacs.d/vendor/yasnippet/snippets")
> (global-set-key "\C-cl" 'org-store-link)
> (global-set-key "\C-ca" 'org-agenda)
> (setq org-log-done 'time)
> (setq org-special-ctrl-k t)
> (org-remember-insinuate)
> (setq org-directory "~/org/")
> (setq org-default-notes-file (concat org-directory "/notes.org"))
> (define-key global-map "\C-cr" 'org-remember)
> (setq org-clock-into-drawer t)
> (setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree))
> (add-hook 'org-mode-hook
>   (lambda ()
>   (org-set-local 'yas/trigger-key [tab])
>   (define-key yas/keymap [tab] 'yas/next-field-group)))
>
>
> I normally have ido enabled, but I disabled it with no change in the behavior.
> Thanks for any suggestions.
>
> Jeff
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2009-09-19 13:03   ` Nicolas Goaziou
@ 2009-09-20 14:16     ` Eric Schulte
  2009-09-21 17:18       ` Carsten Dominik
  0 siblings, 1 reply; 18+ messages in thread
From: Eric Schulte @ 2009-09-20 14:16 UTC (permalink / raw)
  To: Jeff Kowalczyk; +Cc: emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Jeff Kowalczyk <jtk@yahoo.com> writes:
>
>> (add-hook 'org-mode-hook
>>   (lambda ()
>>   (org-set-local 'yas/trigger-key [tab])
>>   (define-key yas/keymap [tab] 'yas/next-field-group)))
>
> According to the yasnippet FAQ (or is it on its forum), it should be
>
> (add-hook 'org-mode-hook
>           #'(lambda ()
>               (setq yas/fallback-behavior
>                     `(apply ,(lookup-key org-mode-map [tab])))
>               (local-set-key [tab] 'yas/expand)))
>
> Anyway, there is one major problem left, it doesn't work with
> org-indent-mode as, when you press TAB to get to the next field of a
> snippet, you are sent to the first headline in the org file.
>
> I have yet to find a workaround about that.
>

After upgrading to the newest version of yasnippet I was dismayed to
find it no longer working in my own org-mode files.  After some painful
trial and error I found that the following setup works for me.

--8<---------------cut here---------------start------------->8---
(defun yas/org-very-safe-expand ()
  (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))

(add-hook 'org-mode-hook
          (lambda ()
            ;; yasnippet (using the new org-cycle hooks)
            (make-variable-buffer-local 'yas/trigger-key)
            (setq yas/trigger-key [tab])
            (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
            (define-key yas/keymap [tab] 'yas/next-field)))
--8<---------------cut here---------------end--------------->8---

-- Eric

>
> Regards,

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

* Re: Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2009-09-20 14:16     ` Eric Schulte
@ 2009-09-21 17:18       ` Carsten Dominik
  2009-09-22 15:52         ` Nicolas Goaziou
  2009-09-22 19:22         ` Eric Schulte
  0 siblings, 2 replies; 18+ messages in thread
From: Carsten Dominik @ 2009-09-21 17:18 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Jeff Kowalczyk, emacs-orgmode

Hi Eric,

could I ask you to update the FAQ with this issue?

Thanks.

- Carsten

On Sep 20, 2009, at 3:16 PM, Eric Schulte wrote:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> Jeff Kowalczyk <jtk@yahoo.com> writes:
>>
>>> (add-hook 'org-mode-hook
>>>  (lambda ()
>>>  (org-set-local 'yas/trigger-key [tab])
>>>  (define-key yas/keymap [tab] 'yas/next-field-group)))
>>
>> According to the yasnippet FAQ (or is it on its forum), it should be
>>
>> (add-hook 'org-mode-hook
>>          #'(lambda ()
>>              (setq yas/fallback-behavior
>>                    `(apply ,(lookup-key org-mode-map [tab])))
>>              (local-set-key [tab] 'yas/expand)))
>>
>> Anyway, there is one major problem left, it doesn't work with
>> org-indent-mode as, when you press TAB to get to the next field of a
>> snippet, you are sent to the first headline in the org file.
>>
>> I have yet to find a workaround about that.
>>
>
> After upgrading to the newest version of yasnippet I was dismayed to
> find it no longer working in my own org-mode files.  After some  
> painful
> trial and error I found that the following setup works for me.
>
> --8<---------------cut here---------------start------------->8---
> (defun yas/org-very-safe-expand ()
>  (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
>
> (add-hook 'org-mode-hook
>          (lambda ()
>            ;; yasnippet (using the new org-cycle hooks)
>            (make-variable-buffer-local 'yas/trigger-key)
>            (setq yas/trigger-key [tab])
>            (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
>            (define-key yas/keymap [tab] 'yas/next-field)))
> --8<---------------cut here---------------end--------------->8---
>
> -- Eric
>
>>
>> Regards,
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2009-09-21 17:18       ` Carsten Dominik
@ 2009-09-22 15:52         ` Nicolas Goaziou
  2009-09-22 19:22         ` Eric Schulte
  1 sibling, 0 replies; 18+ messages in thread
From: Nicolas Goaziou @ 2009-09-22 15:52 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Jeff Kowalczyk, emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> could I ask you to update the FAQ with this issue?

It still doesn't work with org-indent-mode on, though. I guess the FAQ
will have to specify to disable it before using yasnippet (which is a
sad thing as both are providing great features).

-- 
Nicolas Goaziou

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

* Re: Re: Using yasnippet with org Mode (C-i works TAB doesn't)
  2009-09-21 17:18       ` Carsten Dominik
  2009-09-22 15:52         ` Nicolas Goaziou
@ 2009-09-22 19:22         ` Eric Schulte
  1 sibling, 0 replies; 18+ messages in thread
From: Eric Schulte @ 2009-09-22 19:22 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Jeff Kowalczyk, emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hi Eric,
>
> could I ask you to update the FAQ with this issue?
>

done, should update to Worg within the hour -- Eric

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

end of thread, other threads:[~2009-09-22 19:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-23 19:23 Using yasnippet with org Mode Ian Barton
2008-11-23 21:11 ` Eric Schulte
2008-11-23 21:17   ` Tassilo Horn
2008-11-23 22:43     ` Eric Schulte
2008-11-24  9:34       ` Ian Barton
2008-11-24 23:51         ` Sebastian Rose
2008-11-24 14:46       ` Re: Using yasnippet with org Mode [Solved] Ian Barton
2008-11-24 15:38       ` Re: Using yasnippet with org Mode Eric Schulte
2008-11-24  0:45 ` Oliver Charles
2008-11-24 15:40   ` Eric Schulte
2008-11-25 15:44     ` Org mode snippets WAS: " Jonathan Arkell
2009-09-19  5:06 ` Using yasnippet with org Mode (C-i works TAB doesn't) Jeff Kowalczyk
2009-09-19 13:03   ` Nicolas Goaziou
2009-09-20 14:16     ` Eric Schulte
2009-09-21 17:18       ` Carsten Dominik
2009-09-22 15:52         ` Nicolas Goaziou
2009-09-22 19:22         ` Eric Schulte
2009-09-19 13:46   ` Eric Schulte

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).