In a Stack Overflow question, another poster wants to write OpenGL shader programs near to where they are used. However, performance tuning indicates that you should compile these shaders once at the beginning of your program, which means you need access to the shaders in a non-local manner.

Would it be possible to have some indication to "inline" a view of another file? For example, say I had some raw source pseudocode like this:

// ~magic~ shader1.txt
fn my_awesome_method() {
    // do some things

When actually viewing this file, I would see the contents of the file shader1.txt instead of the comment. Ideally, I could even edit it in place, with modifications being written to the original file. In a way, it's kind of like a "live" insert-file, except it isn't modifying the containing file.

This way, the shader would actually be non-local, but you can view and edit it in the context that it will be run in.

  • Besides solving it within Emacs, you can solve it with a pre-processor. A common kind of pre-processor which offers this kind of functionality are the literate programming tools such as tangle.
    – Stefan
    Dec 7, 2015 at 17:44


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.