Problem setting binding -- mode-map does not (yet?) exist

54 views
Skip to first unread message

Jim Burton

unread,
Mar 12, 2010, 8:23:43 AM3/12/10
to smart-snippet and YASnippet
[yas] warning: keybinding "C-?" invalid for snippet "set" since keymap
"latex-mode-map" does not (yet?) exist.

Jim Burton

unread,
Mar 12, 2010, 8:28:31 AM3/12/10
to smart-snippet and YASnippet
[Sorry, I was halfway through writing this post and google groups
posted it for me.]

I've got a problem with this snippet, intended for latex-mode:

# -*- mode: snippet -*-
# name: set
# key: set
# binding: "C-?"
# --
\{ `yas/selected-text`$1 \\}$0

The "name" part works OK, so I can expand "set" in latex-mode, but not
the binding. Here's what I get in *Messages* after loading with C-c C-
c in snippet-mode or yas/reload-all:

[yas] warning: keybinding "C-?" invalid for snippet "set" since keymap
"latex-mode-map" does not (yet?) exist.

How come? Thanks,

Jim

Jim Burton

unread,
Mar 22, 2010, 9:01:28 AM3/22/10
to smart-snippet and YASnippet
I think this is because the keymap is called LaTeX-mode-map, not latex-
mode-map. This is annoying because the mode is called latex-mode, not
LaTeX-mode and I am guessing you derive the name of the keymap from
the path? Defining latex-mode-map fixes it:

(setq latex-mode-map LaTeX-mode-map)

Jim

Jim Burton

unread,
Mar 22, 2010, 9:21:30 AM3/22/10
to smart-snippet and YASnippet
On Mar 22, 1:01 pm, Jim Burton <jimburt...@gmail.com> wrote:
> I think this is because the keymap is called LaTeX-mode-map, not latex-
> mode-map. This is annoying because the mode is called latex-mode, not
> LaTeX-mode and I am guessing you derive the name of the keymap from
> the path? Defining latex-mode-map fixes it:
>
> (setq latex-mode-map LaTeX-mode-map)
>

This only works if it is evaluated after the keymap is defined and
before yas is loaded, but it seems the keymap isn't defined until you
visit a tex file? The only way I can get the keybinding set when I
open a tex file is to add

(setq latex-mode-map LaTeX-mode-map)
(yas/reload-all)

to my LaTeX-mode-hook. I presume there is a better way to do it?

João Távora

unread,
Mar 22, 2010, 10:43:20 AM3/22/10
to smart-...@googlegroups.com
Hi,

It seems you may be right about the case issue. The setq fix, though
it is close, is not what you want, I think. Try

(defvaralias latex-mode-map LaTeX-mode-map)

And report back here. I'll look into the problem as soon as I can.

Bye!

> --
> You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
> To post to this group, send email to smart-...@googlegroups.com.
> To unsubscribe from this group, send email to smart-snippe...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.
>
>

--
João Távora

Jim Burton

unread,
Mar 22, 2010, 10:58:57 AM3/22/10
to smart-snippet and YASnippet
Thinking about this some more, it seems not to be (only) related to
the name of the keymap but the way yas adds bindings to keymaps --
should it not do so by adding a define-key to the _hook_ for each
mode?

Jim

João Távora

unread,
Mar 22, 2010, 11:13:13 AM3/22/10
to smart-...@googlegroups.com
On Mon, Mar 22, 2010 at 3:58 PM, Jim Burton <jimbu...@gmail.com> wrote:
> Thinking about this some more, it seems not to be (only) related to
> the name of the keymap but the way yas adds bindings to keymaps --
> should it not do so by adding a define-key to the _hook_ for each
> mode?

Errr, yes, more or less, it's complicated, but anyway in the trunk and
upcoming 0.7 this problem no longer exists, as a variable called
emulation-mode-maps-alist is used, which simplifies the whole issue
and correctly insulates the mode's maps of all yasnippet interference.

I suspect you're using 0.6something, so I encourage you to try out the trunk:

try svn co http://yasnippet.googlecode.com/svn/trunk yasnippet.

and experiment heavily with keybindings since that's one of the most
underused features. Notice that in the new version, multiple snippets,
even across different modes, can share the same keybinding.

Bye!
J

Jim Burton

unread,
Mar 22, 2010, 11:26:36 AM3/22/10
to smart-snippet and YASnippet
On Mar 22, 3:13 pm, João Távora <joaotav...@gmail.com> wrote:

> On Mon, Mar 22, 2010 at 3:58 PM, Jim Burton <jimburt...@gmail.com> wrote:
> > Thinking about this some more, it seems not to be (only) related to
> > the name of the keymap but the way yas adds bindings to keymaps --
> > should it not do so by adding a define-key to the _hook_ for each
> > mode?
>
> Errr, yes, more or less, it's complicated, but anyway in the trunk and
> upcoming 0.7 this problem no longer exists, as a variable called
> emulation-mode-maps-alist is used, which simplifies the whole issue
> and correctly insulates the mode's maps of all yasnippet interference.
>
> I suspect you're using 0.6something, so I encourage you to try out the trunk:
>
> try svn cohttp://yasnippet.googlecode.com/svn/trunkyasnippet.
>

Yes, I'm using 0.6.1c.

> and experiment heavily with keybindings since that's one of the most
> underused features.

Will do. Thanks,

Jim

Jim Burton

unread,
Mar 22, 2010, 11:41:13 AM3/22/10
to smart-snippet and YASnippet
The version from svn seems to be broken for me. Loading a tex document
I get no yas menu and none of the snippets aredefined. I have added
the defvaralias to LaTeX-mode-hook, and get this in *Messages*:

[...]
[yas] Warning: the "# group:" is no longer supported! [80 times]
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading tramp...done
Automatic display of crossref information was turned on
Starting new Ispell process [default] ...
File mode specification error: (void-variable latex-mode-map)
Applying style hooks...
Loading /home/jim/sdf-git/papers/thesis/auto/main.el (source)...done
Applying style hooks... done
File mode specification error: (void-variable latex-mode-map)
[end of messages]

Removing the defvaralias has no effect.

Jim

On Mar 22, 3:13 pm, João Távora <joaotav...@gmail.com> wrote:

João Távora

unread,
Mar 22, 2010, 1:08:34 PM3/22/10
to smart-...@googlegroups.com
Obviously, being a version currently under development, you must bear
with some instabilities. :-) can you reproduce this with a clean
emacs -Q run?

like "emacs -Q -l yasnippet.el -l simpleinit.el"

where simpleinit.el would just contain

(setq yas/snippet-dirs <dir-or-list-of-dirs>)
(yas/reload-all)

If it doesn't happen, then its a problem with your previous config. It
if still happens, post a zip of your latex snippets here, or better
yet, all your snippet dirs, as long as they're relatively small.

PS: I don't think the defvaralias matters anymore. It was just a
workaround for 0.6.1, did you try it?

Thanks!
J

Jim Burton

unread,
Mar 22, 2010, 1:32:35 PM3/22/10
to smart-snippet and YASnippet

On Mar 22, 5:08 pm, João Távora <joaotav...@gmail.com> wrote:
> Obviously, being a version currently under development, you must bear
> with some instabilities.  :-) can you reproduce this with a clean
> emacs -Q run?
>
> like "emacs -Q -l yasnippet.el -l simpleinit.el"
>
> where simpleinit.el would just contain
>
> (setq yas/snippet-dirs <dir-or-list-of-dirs>)
> (yas/reload-all)
>

This loads without any errors (*Messages* contains the warnings from
before but no errors). I can see two problems though: there are no
submenus beneath text-mode, just a long list with every snippet
listed, and although I can select a snippet from the menu, neither tab-
expansion or bindings work. I'm using Gnu Emacs 23.0.91.1.

> If it doesn't happen, then its a problem with your previous config. It
> if still happens, post a zip of your latex snippets here, or better
> yet, all your snippet dirs, as long as they're relatively small.
>
> PS: I don't think the defvaralias matters anymore. It was just a
> workaround for 0.6.1, did you try it?

Yes I did, and 0.6.1c is working fine for me with that, so I'm quite
happy to stick to that version for now.

Thanks,

Jim

João Távora

unread,
Mar 22, 2010, 6:45:53 PM3/22/10
to smart-...@googlegroups.com
Did you use your own snippets or the snippets in the trunk? In other words, what did you use as
>>
>> (setq yas/snippet-dirs <dir-or-list-of-dirs>)

If you used your own snippet collection please post it here so I can debug this problem.

Thanks,
Joao

Jim Burton

unread,
Mar 23, 2010, 6:59:41 AM3/23/10
to smart-snippet and YASnippet
I was using my own snippets and I discovered that there was a non-
snippet file in amongst them, a lisp file generated by AUCTeX (I think
I accidentally compiled one of the snippet files somehow). Removing
this file fixed the problem.

Thanks for your help.

Jim

João Távora

unread,
Mar 23, 2010, 8:48:15 AM3/23/10
to smart-...@googlegroups.com
OK, so just to confirm. You *can* use the svn trunk (upcoming 0.7)
correctly with your AUCTeX snippets, together with the bundled
snippets.

It's strange about that file, but I'm glad it works. From the
behaviour you described earlier (big list of snippets under
text-mode), I would have guessed you tried to use the 0.6 snippet
collection with 0.7, which is incompatible and would produce just
that, since the hierarchy organization has been completely replaced by
the used of ".yas-parents".

So have fun and report any strange behaviour here,
João

Reply all
Reply to author
Forward
0 new messages