chasberry / orgmode-accessories

Add ons for orgmode
78 stars 18 forks source link

Default ravel properties #26

Closed fkgruber closed 1 year ago

fkgruber commented 1 year ago

Hi I was trying the latest ox-ravel and I see a big change in behavior. Before I could specify properties to be assign to every code. For example:

:PROPERTIES:
:header-args:R: :exports both :ravel echo=FALSE,eval=TRUE
:header-args: :ravel echo=TRUE,eval=TRUE,results='markup',message=FALSE,cache=FALSE
:EXPORT_FILE_NAME: myfilename
:END:

then when we exported the Rmd all this properties would be assigned to each block. We could then modify any additional block by adding

+attr_ravel: eval=FALSE

before the block.

If I do that now I get an error of repeated eval. How can I do something similar on the new version?

chasberry commented 1 year ago

The older style for chunk options didn't care about duplicates -- the later option of the same name overrode the earlier, but I guess the yaml processing does.

After starting emacs and loading ox-ravel, eval this block to override the existing function:

#+begin_src emacs-lisp
(defun ox-ravel--args-alist (argstring)
    "Return all arguments as an alist with cars set to argument
  names and cdrs set to the expressions given as argument. Both
  cars and cdrs are returned as strings."
    (with-temp-buffer
      (insert argstring)
      (ess-r-mode)
      (beginning-of-buffer)
      (let (args current-arg alst elt (blst ()))
    (while (and (setq current-arg (ess-cons-arg))
            (setq args (nconc args (list current-arg)))
            (ess-jump-to-next-arg)))
    (setq alst (assoc-delete-all nil args))

    (while alst
      (setq elt (pop alst))
      (unless (assoc (car elt) alst) (push elt blst)))
    (reverse blst))))
#+end_src

and see if this cures the problems you had. If this works, I'll commit this and push it.

Note that babel treats `ravel' as its own language, viz. header args from other languages are ignored - including R.

If you want to use properties just for ravel blocks, use :header-args:ravel: <etc>.

Also note, ravel alters some header args, especially :export which is set of results to enable ravel processing.

Please reply with an ECM if this still doesn't address the problems you are having.

chasberry commented 1 year ago

After pushing the above, I will close this issue. Feel free to re-open if problems arise.