emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: Mark Elston <m_elston@comcast.net>
Cc: org-mode emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Use with yasnippets?
Date: Thu, 23 Apr 2009 21:43:31 -0400	[thread overview]
Message-ID: <87prf2q118.fsf@gollum.intra.norang.ca> (raw)
In-Reply-To: <49F0F58D.7070109@comcast.net> (Mark Elston's message of "Thu\, 23 Apr 2009 16\:11\:09 -0700")

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

  reply	other threads:[~2009-04-24  1:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-23 23:11 Use with yasnippets? Mark Elston
2009-04-24  1:43 ` Bernt Hansen [this message]
2009-04-24  1:48   ` Mark Elston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87prf2q118.fsf@gollum.intra.norang.ca \
    --to=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=m_elston@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).