help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question Regarding Trying To Implement Yasnippet Templates To Wrap S


From: Yuri Khan
Subject: Re: Question Regarding Trying To Implement Yasnippet Templates To Wrap Source Blocks Around Regions
Date: Fri, 7 Jan 2022 02:21:08 +0700

On Fri, 7 Jan 2022 at 01:58, Samuel Banya <sbanya@fastmail.com> wrote:

> I'm trying to figure out how to utilize a Yasnippet template to wrap a source 
> block around a section of code that I've highlighted.
>
> Here's the template I used in 
> '/home/sam/hub/dotfiles/emacs/.emacs.d/snippets/org-mode':
>
> # -*- mode: snippet -*-
> # name: wrapsrc
> # key: C-;
> # expand-env: ((yas-wrap-around-region t))
> # --
> #+begin_src $1
>   $0
> #+end_src

You are not telling us how exactly you tried to expand that, what you
expected and what happened instead, so I’ll venture a guess: You’re
pressing Ctrl+semicolon and it does not expand. Instead, Emacs tells
you “C-; is undefined”.

According to docs[1], you need the ‘# binding:’ (not ‘# key:’) keyword
to set the key that will expand the snippet. Alternatively, you could
type your snippet’s key (that’s capital letter C, followed by hyphen,
followed by semicolon), then press TAB, and it might expand; but I
guess that’s not what you meant to do.

[1]: https://joaotavora.github.io/yasnippet/snippet-development.html#org67f4e69

Also I hope you’re doing that in a GUI frame and not in a terminal.
Not many terminals can faithfully deliver the Ctrl+semicolon
keystroke.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]