I am trying to create an org-capture template which works with yankpad and yasnippets to such that if I am working with some c code like this:
example.c
static int somefunc(int a) {
if (a ==5) {
return 1;
}
else {
return 0;
}
}
I want to be able to, with a single org-capture, yank the entirety of the function and its signature into an org file like so:
example.org
#+NAME: example_proto
#+BEGIN_SRC C
int somefunc(int a);
#+END_SRC
#+NAME: example_func
#+BEGIN_SRC C
static int somefunc(int a) {
if (a ==5) {
return 1;
}
else {
return 0;
}
}
#+END_SRC
This requires the following:
- Get the scope of the current function.
- Get the prototype of the current function.
- Pass these into an org-capture template.
- Use yasnippets in the org-capture template.
The main piece I can't figure out is how to find out what function defines the current scope programmatically so that I can pass it as an argument to other elisp functions (to determine scope, callees, etc).
If someone can point me in the right direction that'd be much appreciated.