ok, thanks for confirming!

I tried a workaround like this:

#+BEGIN_SRC emacs-lisp -r
(defun my-tangle-with-r ()
  (interactive)
  (let* ((temporary-file-directory ".")
(tmpname (make-temp-file "switch" nil ".org"))
buf
data)
    (write-region (point-min) (point-max) tmpname)
    (setq buf (find-file-noselect tmpname))
    (with-current-buffer buf
      (setq data (org-element-parse-buffer))
      (org-element-map data 'src-block
(lambda (src)
  (org-element-put-property src :switches "-r")))
      (erase-buffer)
      (insert (org-element-interpret-data data))
      (save-buffer)
      (org-babel-tangle))
    (kill-buffer buf)
    (delete-file tmpname)))
#+END_SRC

Any suggestions for improvement? It seems to work for me, but says it
tangled from the temp file instead of the main file (that is expected, but
not ideal). I tried some simpler ways but with org-export-with-buffer-copy,
for example, I ran into difficulties because of the buffer modification,
which I could find a way around that didn't lead to many copies of the
buffer being open. In this solution, I just save it and have no issue there.

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Fri, Sep 28, 2018 at 3:16 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> John Kitchin <jkitc...@andrew.cmu.edu> writes:
>
> > I am working on a pretty large literate program right now, and am using
> > coderefs in the blocks. I know I can add a -r switch to a code block to
> > remove the labels, but there are /a lot/ of blocks, and I wondered if
> there
> > was some way to specify a file-wide switch, or a language specific
> switch?
> > It isn't obvious that is possible, so I thought I would ask.
>
> No, there is not.
>
> Regards,
>
> --
> Nicolas Goaziou
>

Reply via email to