Auto-including attributes to Babel Result blocks

Preamble

Recently I have been using org-mode to do some matlab heavy school assignments (via Mathworks-MATLAB-mode.

[aside: I am aware of GNU Octave. I have used it in the past but it simplifies getting help from instructors/TAs to just use Matlab.]

Once I tracked down a latex template (courtesy of straight forward emacs) I have a tidying way of cranking out assignments that does most of what I want.

Attaching #+attr to #+RESULTS

The vast majority of what I am doing with code blocks for assignments is creating figures/graphs for assignments so I’m using :results file graphics

It would be great if I could either:

  1. Include a set of default #+attr_ (centering the result in emacs, sizing, turning off float, etc).
  2. Get a prompt for #+attr_ on eval of a code block.

It’s not super clear to me how to go about achieving this.

Reading the ‘graphics’ section of Results of Evaluation (The Org Manual) graphics results are just file links that get dropped in current directory unless otherwise specified.

Possible approaches

  1. org-babel-after-execute-hook - currently this is how I get the inserted image to be displayed in the buffer after execution however, adding #+attr_ seems like a more complex task than calling a single function.
  2. Something to do with the link system?
  3. Some config variable I am totally unaware for this purpose - I know that org-babel-default-header-args exists for setting default header args but I’ve not been find anything for dealing with the result.

Pointers in a helpful direction would be appreciated.

1 Like