joaotavora / yasnippet

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

Yasnippets in .Rnw files: TAB-expansion not working anymore #231

Closed mhofert closed 11 years ago

mhofert commented 12 years ago

Hi,

I have exactly the problem as described here: http://groups.google.com/group/smart-snippet/browse_thread/thread/8206a23037f598b1/39ed819692df63ad?lnk=gst&q=rnw&pli=1 Unfortunately, the described solution does not work -- TAB does not expand (ya)snippets in my .Rnw files. You can find a detailed description of the problem on: http://tex.stackexchange.com/questions/49530/yasnippet-sweave-how-to-make-snippets-work-from-rnw-files I work on Mac OS X 10.7.3 with the very latest version of R (and ESS) and yasnippet-0.6.1c.

Cheers,

Marius

joaotavora commented 12 years ago

Please try upgrading to the latest HEAD version of yasnippet, found on github and check back here. Do not use the workaround described in the thread since it is out of date. I'm away from my computer at the moment but will have a look at this soon. Thanks.

On Sat, Mar 31, 2012 at 7:33 AM, mhofert < reply@reply.github.com

wrote:

Hi,

I have exactly the problem as described here:

http://groups.google.com/group/smart-snippet/browse_thread/thread/8206a23037f598b1/39ed819692df63ad?lnk=gst&q=rnw&pli=1 Unfortunately, the described solution does not work -- TAB does not expand (ya)snippets in my .Rnw files. You can find a detailed description of the problem on:

http://tex.stackexchange.com/questions/49530/yasnippet-sweave-how-to-make-snippets-work-from-rnw-files I work on Mac OS X 10.7.3 with the very latest version of R (and ESS) and yasnippet-0.6.1c.

Cheers,

Marius


Reply to this email directly or view it on GitHub: https://github.com/capitaomorte/yasnippet/issues/231

Joo Tvora

mhofert commented 12 years ago

Thanks a lot for your quick response. I'll give it a try and get back to you.

mhofert commented 12 years ago

I installed the latest version from https://github.com/capitaomorte/yasnippet/tree/jit-loading. The problem remains. I can use M-x yas/expand to expand a snippet when the point is in the LaTeX part of an .Rnw file, but I can't use TAB to expand a snippet.

mhofert commented 12 years ago

Hi, did you have a chance to look at it so far? Can you reproduce the problem?

joaotavora commented 12 years ago

Hi.

The problem is that noweb-minor-mode-map already defines [tab] as a local keybinding for noweb-indent-line.

  1. I would recommend that you try out the "tighter-tab" branch, available from https://github.com/capitaomorte/yasnippet/tree/tighter-tab. I plan to merge this into the trunk once I have sufficient confidence with unit tests in place. The reason I haven't done it so far is that it hinges on yasnippet taking advantage of a super-keymap that is superior to all the other keymaps and I still don't know how "legal" that is.
  2. Alternatively you can use

    (add-hook 'ess-mode-hook #'(lambda () (local-set-key [tab] 'yas/expand)))

in the normal master branch, and maybe even the older 0.6 version (though I recommend you upgrade to the latest, however poorly documented it is).

Either way, as always, if yasnippet finds nothing to do, it should call the fallback binding.

Hope this works, Joo Tvora

On Wed, Apr 4, 2012 at 12:30 PM, mhofert < reply@reply.github.com

wrote:

Hi, did you have a chance to look at it so far? Can you reproduce the problem?


Reply to this email directly or view it on GitHub: https://github.com/capitaomorte/yasnippet/issues/231#issuecomment-4951569

Joo Tvora

mhofert commented 12 years ago

Dear Joo,

  1. I tried your first solution. Still, tab-expansion does not work. I am not sure if I installed the tighter branch correctly. I went to the URL you provided and did:

cd ~/.emacs.d/plugins git clone https://github.com/capitaomorte/yasnippet

Something I am wondering: That's precisely the same git command as is used for the other branch(es). Is that correct? Because if it is wrong, it might be that I haven't installed the tighter branch correctly.

  1. I then tried your second solution. But also here, I can use M-x yas/expand to expand a snippet, but not TAB. Note that I'm using the latest version (12.04) of ESS. Is this a problem? When I start R and check ess-mode-hook (through customization), I see the entry (lambda nil (local-set-key tab)). Still, it does not seem to work.

Cheers,

Marius

joaotavora commented 12 years ago

On Sun, Apr 8, 2012 at 9:22 AM, mhofert < reply@reply.github.com

wrote:

Dear Joo,

  1. I tried your first solution. Still, tab-expansion does not work. I am not sure if I installed the tighter branch correctly. I went to the URL you provided and did:

cd ~/.emacs.d/plugins git clone https://github.com/capitaomorte/yasnippet

Something I am wondering: That's precisely the same git command as is used for the other branch(es). Is that correct? Because if it is wrong, it might be that I haven't installed the tighter branch correctly.

  1. I then tried your second solution. But also here, I can use M-x yas/expand to expand a snippet, but not TAB. Note that I'm using the latest version (12.04) of ESS. Is this a problem? When I start R and check ess-mode-hook (through customization), I see the entry (lambda nil (local-set-key tab)). Still, it does not seem to work.

Cheers,

Marius


Reply to this email directly or view it on GitHub: https://github.com/capitaomorte/yasnippet/issues/231#issuecomment-5014059

  1. To try out a a specific branch, you have to switch to it after cloning (there are other ways). But basically you have to git checkout tighter-tab in the repository dir after cloning, then make sure emacs sees the new yasnippet.el
  2. This should also work, I don't understand why not. I'm not in front of my computer right now, but try this directly in a buffer where you are experiencing the problem

M-x eval-expression RET (local-set-key [tab] 'yas/expand) RET

or maybe try this variation

M-x eval-expression RET (local-set-key (kbd "TAB") 'yas/expand) RET

If the second variation works, use that instead of the one I provided in the previous reply.

Joo Tvora

mhofert commented 12 years ago

Thanks very much, Joo. I could switch to the tighter-tab branch and it now works! It would be great if this feature was also in the "standard" branch.

mhofert commented 12 years ago

Unfortunately, I was too fast. Switching to the tighter-tab branch interferes with org-mode. It is not possible to expand sections in an org-file anymore with tab....

mhofert commented 12 years ago

Concerning your other solution:

1) M-x eval-expression RET (local-set-key [tab] 'yas/expand) RET => this works when executed from within the .Rnw file. However, it does not work anymore when I have it in .emacs. How can I make this work from within .emacs?

2) M-x eval-expression RET (local-set-key (kbd "TAB") 'yas/expand) RET => this does not work when executed locally in the .Rnw file.

mhofert commented 12 years ago

I guess I found something. This code solved it (for now):

(add-hook 'LaTeX-mode-hook '(lambda() (local-set-key [tab] 'yas/expand)))

I was wondering about the ess-mode-hook since at the point where I want to expand snippets the mode of the file is LaTeX and not ESS/R anymore. So simply replace ess-mode-hook by LaTeX-mode-hook and it should work.

I will test that and (if necessary) get back to you (if it doesn't work).

Cheers,

Marius

npostavs commented 11 years ago

Closing as solved.