10

I've been Googling and digging through the org-babel docs, but it's coming out with not a lot.

The thing is, one of things I'm working on is using org-babel to tangle Makefile source. In it, the documentation states, and I understand why it does, that I need to evaluate (setq org-src-preserve-indentation t), which I have, right now.

Thing is, I don't want to enable this value globally. I can understand that it makes sense for Python, Makefile, or other languages that are white-space sensitive, but I really don't want it enabled elsewhere. Plus, the end result of this is that the final org-file won't work for people who don't enable the value by default, so the resulting org-file is less portable anyway.

I'd prefer it if I could just enable org-src-preserve-indentation on a per code-block basis (it's extra typing, but I can live with that), but even a buffer-specific setting is acceptable. The thing is, I'm not sure how to do it.

I suspect that it could be done by taking advantage of how #+HEADER settings can eval Lisp code, but doesn't that mean that every time I tangle the file, or something, the setting is kept on every time? I'd rather not do that, that just makes the file unpredictable to use.

Tariq Kamal
  • 390
  • 1
  • 9

1 Answers1

5

Based on feedback I received from the Google+ org-mode group, as well as reading up on buffer-local variables, I finally ended up using M-x add-file-local-variable RET org-src-preserve-indentation RET t to finally add this code block at the bottom of my org-file:

# Local Variables:
# org-src-preserve-indentation: t
# End:

Once I refresh the local setup (i.e. press C-c on the header arguments), Emacs asks me if I want to use the buffer local variable, and then sets org-src-preserve-indentation to t for this buffer alone.

This appears to resolve the issue to my liking, so I'm going to mark this question closed.

Tariq Kamal
  • 390
  • 1
  • 9