Suppose I have a lot of small text snippets (including some LaTeX-code).
Now I want to create a LaTeX document with emacs which includes some of the text snippets. I know yasnippet which can expand keywords to the snipped but that's not what I want. Instead I am looking for something like this:
- Invoke an emacs command
insert-snippet
- Then I can browse, search filter and select one (or at best also multiple snippets)
- The snippets should not be copied to the file but included via an LaTeX input statement say
\input{snippet1}
(or if multiples are selected:\input{snippet1}
\input{snippet5}
.
If I edit the main file and point is on say \input{snippet3}
there should be a command to view the content of this snippet (any maybe replace it by another one).
The approach described above seems to require that each snippet is saved in a separate file - otherwise the \input
statement wouldn't work. However this seems to make it harder to edit the snippets. Maybe one option would be to edit them using the multifiles package (then you can edit them just as they where one file) or just grep them with helm-do-grep
and browse it with executing helm-persistent-action
...
Another idea would be to use another command instead of \input
like \ExecuteMetaData[inputfile]{mytag1}
from the catchfilebetweentags
package. Then you could store them in one file.
Another option would be to store the snippets in one file like
\newcommand{\mysnippet1}{
Snippet Text
}
Some text or comments.
\newcommand{\mysnippet2}{
Snippet Text
}
And then input \mysnippet2
instead of \input{mysnippet2}
.
If no library exists which does what I want, what would you suggest where to start to realize this by myself?
browse-kill-ring
uses a list to generate possible insertions, and it may be possible to borrow some of that functionality by gathering the contents of the snippets and offering them as options. I'm not suggesting thatbrowse-kill-ring
is the answer -- I'm only suggesting that seeing what makes it tick might be helpful when creating your own library.