emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)


From: Eric Schulte
Subject: Re: [Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Date: Sun, 20 Sep 2009 08:16:02 -0600
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (darwin)

Nicolas Goaziou <address@hidden> writes:

> Jeff Kowalczyk <address@hidden> 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,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]