joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.78k stars 312 forks source link

org mode src block tab stop fields do not work #762

Closed ag91 closed 7 years ago

ag91 commented 7 years ago

Hello, first of all this mode is a jewel! Thanks for your effort in developing it and maintaining it!!

My issue is that when I try to create a snippet for org mode that has a bit sophisticated src block, the tab stop fields are not considered at all. Indeed, the snippet is statically inserted. The snippet I am trying to write is

# -*- mode: snippet -*-
# name: ditaa
# key: ditaa_
# --
#+begin_src sh :results silent :exports results
cat << end_file > ${1:/tmp/testimage.txt}
   @startditaa
   $0
   @endditaa

end_file

plantuml $1
#+end_src

[[${1:$(concat (file-name-sans-extension yas-text) ".png")}]]

but when I try to insert it I get always the following, without being able to edit it:

#+begin_src sh :results silent :exports results
cat << end_file > /tmp/testimage.txt
   @startditaa

   @endditaa

end_file

plantuml /tmp/testimage.txt
#+end_src

[[/tmp/testimage.png]]

I checked other snippets that use source blocks (e.g., dot_), but it seems none of them contains text in the blocks. I am using yasnippet 20161211.1918 from MELPA. Thanks again for this fantastic software tool!

npostavs commented 7 years ago

What org version are you using? Have you set org-src-tab-acts-natively and/or org-src-fontify-natively? I think this might be the same problem described in https://github.com/joaotavora/yasnippet/issues/761#issuecomment-267713624

ag91 commented 7 years ago

I am using org-plus-contrib 20161031 from MELPA. I did not know those options, and they are not set on my system. I read the comments of the other issue, but I am not sure about the explanation: why for the following snippet $0 $1 $2 work fine?

# -*- mode: snippet -*-
# name: dot
# key: dot_
# --
#+begin_src dot :file ${1:file} :cmdline -T${2:pdf} :exports results :results silent
            $0
#+end_src
npostavs commented 7 years ago

Doesn't happen here, both snippets expand fine with working fields. Can you reproduce this from emacs -Q?

ag91 commented 7 years ago

I spent few hours trying to find the problem, and I discovered that in a corner of my config.el both org-src-tab-acts-natively and org-src-fontify-natively were indeed set to true. Sorry for this. Removing the setting of org-src-tab-acts-natively solved this issue. Thanks again for your help and yasnippet!

npostavs commented 7 years ago

Thanks for confirming, I'm closing this as a dup of #761 then.