From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: Using yasnippet with org Mode (C-i works TAB doesn't) Date: Sun, 20 Sep 2009 08:16:02 -0600 Message-ID: References: <4929ADBB.6050809@manor-farm.org> <87iqff6q81.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MpNCx-0004sl-SQ for emacs-orgmode@gnu.org; Sun, 20 Sep 2009 10:16:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MpNCx-0004sT-DC for emacs-orgmode@gnu.org; Sun, 20 Sep 2009 10:16:07 -0400 Received: from [199.232.76.173] (port=56722 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MpNCx-0004sL-0B for emacs-orgmode@gnu.org; Sun, 20 Sep 2009 10:16:07 -0400 Received: from qw-out-1920.google.com ([74.125.92.148]:26109) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MpNCw-00081l-O2 for emacs-orgmode@gnu.org; Sun, 20 Sep 2009 10:16:06 -0400 Received: by qw-out-1920.google.com with SMTP id 5so759486qwf.24 for ; Sun, 20 Sep 2009 07:16:05 -0700 (PDT) In-Reply-To: <87iqff6q81.fsf@gmail.com> (Nicolas Goaziou's message of "Sat, 19 Sep 2009 15:03:58 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jeff Kowalczyk Cc: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Jeff Kowalczyk 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,