all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Question Regarding Trying To Implement Yasnippet Templates To Wrap Source Blocks Around Regions
@ 2022-01-06 18:58 Samuel Banya
  2022-01-06 19:21 ` Yuri Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Banya @ 2022-01-06 18:58 UTC (permalink / raw)
  To: Emanuel Berg

Hey there,

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

Here are the links I tried referring to as references:
https://joaotavora.github.io/yasnippet/snippet-reference.html#yas-wrap-around-region

https://gist.github.com/kazu634/290872

https://emacs.stackexchange.com/questions/35557/how-can-i-define-a-yasnippet-for-if-and-if

https://stackoverflow.com/questions/9082999/how-to-insert-a-latex-environment-around-a-block-of-text-in-emacs

Any ideas on how to do this?

Thanks,

Sam


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question Regarding Trying To Implement Yasnippet Templates To Wrap Source Blocks Around Regions
  2022-01-06 18:58 Question Regarding Trying To Implement Yasnippet Templates To Wrap Source Blocks Around Regions Samuel Banya
@ 2022-01-06 19:21 ` Yuri Khan
  2022-01-06 21:42   ` Samuel Banya
  0 siblings, 1 reply; 3+ messages in thread
From: Yuri Khan @ 2022-01-06 19:21 UTC (permalink / raw)
  To: Samuel Banya; +Cc: Emanuel Berg

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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question Regarding Trying To Implement Yasnippet Templates To Wrap Source Blocks Around Regions
  2022-01-06 19:21 ` Yuri Khan
@ 2022-01-06 21:42   ` Samuel Banya
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Banya @ 2022-01-06 21:42 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Emanuel Berg

Hey there Yuri,

Sorry to not be complete about my previous email.

To be more specific:
- I opened up my GUI Emacs
- I made a quick Org mode buffer, and put in some example Bash lines:
dir
ls

- I then highlighted this same sets of commands, and hit 'C-;' and then hit Tab.

- When I did the above actions, I get the following shown in the Helm Mini Buffer:
'C-; is undefined'
EMPTY EMPTY

Hoping that helps a bit :)

Sincerely,

Sam

On Thu, Jan 6, 2022, at 2:21 PM, Yuri Khan wrote:
> 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.
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-06 21:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-06 18:58 Question Regarding Trying To Implement Yasnippet Templates To Wrap Source Blocks Around Regions Samuel Banya
2022-01-06 19:21 ` Yuri Khan
2022-01-06 21:42   ` Samuel Banya

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.