How do I resolve keybinding conflict? Or if it's possible to have precedence of keybindings for the same key for different functions?

I have the following snippet definition, in org-mode:

#+begin_src ${1:lang}
$0 $2

It expands to the following:

#+begin_src lang

text-wise, it looks correct. But after the expansion, the fields of variable substitution are not highlighted for substitution. I cannot use TAB to update the name and lang, instead TAB would fold the expanded snippet as shown below:

#+begin_src lang...

It triggers function org-cycle as the cursor is just on the line of #+name:

Would it be possible to let the keybindings of TAB for snippet field substitution have higher precedence over org-cycle, so that when it's possible for snippet field substitution, then TAB will do the snippet field substitution, otherwise the ordinary org-cycle in this case?

I also welcome any other solution to make this snippet work in org-mode.

  • What is snippet field substitution? (What is the command? Which library provides it?)
    – phils
    Commented Jul 13, 2020 at 2:35
  • The package is snippet. But I don't know the function exact for snippet field substitution. I mean the function that is supposed to be triggered by the 2nd key press TAB , when the first key press TAB to trigger snippet expansion. The 2nd is supposed to trigger the field substitution.
    – Yu Shen
    Commented Jul 13, 2020 at 4:47
  • Ask Emacs. Use C-h k TAB to learn which command is bound to TAB.
    – phils
    Commented Jul 13, 2020 at 9:29


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.