Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mhofert opened this issue Mar 31, 2012 · 12 comments
Closed

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

mhofert opened this issue Mar 31, 2012 · 12 comments

Comments

@mhofert
Copy link

mhofert commented Mar 31, 2012

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
Copy link
Owner

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:
#231

Joo Tvora

@mhofert
Copy link
Author

mhofert commented Apr 1, 2012

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

@mhofert
Copy link
Author

mhofert commented Apr 1, 2012

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
Copy link
Author

mhofert commented Apr 4, 2012

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

@joaotavora
Copy link
Owner

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:
#231 (comment)

Joo Tvora

@mhofert
Copy link
Author

mhofert commented Apr 8, 2012

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](quote
    yas/expand))). Still, it does not seem to work.

Cheers,

Marius

@joaotavora
Copy link
Owner

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](quote
    yas/expand))). Still, it does not seem to work.

Cheers,

Marius


Reply to this email directly or view it on GitHub:
#231 (comment)

  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
Copy link
Author

mhofert commented Apr 8, 2012

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 mhofert closed this as completed Apr 8, 2012
@mhofert mhofert reopened this Apr 8, 2012
@mhofert
Copy link
Author

mhofert commented Apr 8, 2012

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
Copy link
Author

mhofert commented Apr 8, 2012

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
Copy link
Author

mhofert commented Apr 8, 2012

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
Copy link
Collaborator

Closing as solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants