Edit: While I'm still learning the ropes of Babel, I've read about the system-type
, emacs-version
, and window-system
variables, which sound like they contain all the information I need to get the behavior I've described here. In fact, I could just wrap OS-specific code in conditionals when needed in code blocks. I'm wondering if this is the best way to go about this, however.
I'm using Babel to write literate configuration files for Emacs. I would like my config files to work on all of the platforms I frequently use (so basically various Linux distros and Macs), and part of this involves having settings that depend on the system (e.g., the default font I use on my Mac is different than the one I use on Linux Mint).
While I'm sure I've seen ways to recognize whether or not I'm on a Mac using elisp (and hence could wrap any system-specific settings in some kind of conditional based on this), I'm wondering if Org/Babel has some way to detect the type of system I'm on which would enable me to write different code blocks for different systems. Better yet, can this also be done for different versions of Emacs? I'm envisioning code that would look something like the following (with platform and header names being contrived examples)
#+Platform: LinuxMint
#+Emacs: GNU Emacs
#+EmacsVersion: 24+
#+BEGIN_SOURCE EMACS-LISP
[Some configuration for Linux Mint and GNU Emacs 24+]
#+END_SOURCE
#+Platform: LinuxMint
#+Emacs: GNU Emacs
#+EmacsVersion: 22.1
#+BEGIN_SOURCE EMACS-LISP
[Some other configuration for Linux Mint and GNU Emacs 22.1]
#+END_SOURCE
#+Platform: Mac
#+Emacs: Aquamacs
#+EmacsVersion: 24+
#+BEGIN_SOURCE EMACS-LISP
[Some other configuration for Mac and Emacs 24+]
#+END_SOURCE
The big fish to fry is the platform, since the version of emacs and the emacsen I use can probably be inferred from this in most situations. I should mention that the platform could be coarser than what I suggest above. (I really just need to know if I'm on a Linux, Windows, or Mac distribution.) Also, if these aren't built-in features, how would I go about creating code-block headers like these?
Edit: I suppose it might also be more likely to look something like the following.
#+BEGIN_SOURCE EMACS-LISP :os Linux :emacs GNU :emacs-version 24+
[Some configuration for Linux and GNU Emacs 24+]
#+END_SOURCE
I imagine this can be found somewhere in the documentation if it exists but I couldn't seem to find a comprehensive list of headers for code blocks. Thanks for any help you can provide!