Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#+INCLUDE support for embedding source code #75

Open
falloutphil opened this issue Mar 28, 2020 · 1 comment
Open

#+INCLUDE support for embedding source code #75

falloutphil opened this issue Mar 28, 2020 · 1 comment

Comments

@falloutphil
Copy link

falloutphil commented Mar 28, 2020

Hi,

I'm using this on github for rendering my README.org file.

Whilst BEGIN_SRC and END_SRC blocks work a charm, you don't seem to be able to reference part of a file in the same repo, for example something like the below would use a relative path to the README.org file that contains the reference:

#+INCLUDE: "./elhome/settings/foo-settings.el" src emacs-lisp :lines "2-20"

This would be immensely useful for cases where I am unable to use literate programming techniques to refactor my elisp files into org file using babel.

My guess is the grunt work could reuse what is already there form BEGIN/END_SRC support.

@melioratus
Copy link

@falloutphil - The #+INCLUDE: syntax is available in org-ruby but requires two environmental variables to be set at run time to to enable the functionality.
See parser.rb#L102

      #
      # Include file feature disabled by default since 
      # it would be dangerous in some environments
      #
      # http://orgmode.org/manual/Include-files.html
      #
      # It will be activated by one of the following:
      #
      # - setting an ORG_RUBY_ENABLE_INCLUDE_FILES env variable to 'true'
      # - setting an ORG_RUBY_INCLUDE_ROOT env variable with the root path
      # - explicitly enabling it by passing it as an option:
      #   e.g. Orgmode::Parser.new(org_text, { :allow_include_files => true })
      #
      # IMPORTANT: To avoid the feature altogether, it can be _explicitly disabled_ as follows:
      #   e.g. Orgmode::Parser.new(org_text, { :allow_include_files => false })
      #

As a workaround for this default configuration setting, I started to export README.org and other common files from a dedicated file, common-project-files.org.

Note: At the time of this post, the README.org section in common-project-files.org does not use #+INCLUDE: statements but I plan to add this feature because I would like to add usage and other code examples from other files in my projects.

Hope that helps.

Melioratus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants