From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: file wide/language specific switches? Date: Fri, 28 Sep 2018 14:36:09 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000005c36f50576f2bb54" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5xcv-00042y-23 for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 14:36:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5xcp-0000x5-Mv for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 14:36:32 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:44471) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5xcm-0000rr-Sz for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 14:36:26 -0400 Received: by mail-wr1-x42c.google.com with SMTP id 63-v6so116153wra.11 for ; Fri, 28 Sep 2018 11:36:22 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org-mode-email --0000000000005c36f50576f2bb54 Content-Type: text/plain; charset="UTF-8" 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. Thanks, 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 --0000000000005c36f50576f2bb54 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 cod= e block to remove the labels, but there are /a lot/ of blocks, and I wonder= ed if there was some way to specify a file-wide switch, or a language speci= fic switch? It isn't obvious that is possible, so I thought I would ask= .

Thanks,
=C2=A0
John

----------------------------= -------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Department= of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15= 213
412-268-7803
--0000000000005c36f50576f2bb54-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: file wide/language specific switches? Date: Fri, 28 Sep 2018 21:16:08 +0200 Message-ID: <8736tt77rb.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yFd-00009H-78 for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 15:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5yFa-0004U9-20 for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 15:16:33 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:37073) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5yFZ-0004TU-QK for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 15:16:29 -0400 In-Reply-To: (John Kitchin's message of "Fri, 28 Sep 2018 14:36:09 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: John Kitchin Cc: org-mode-email Hello, John Kitchin 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: file wide/language specific switches? Date: Fri, 28 Sep 2018 15:59:16 -0400 Message-ID: References: <8736tt77rb.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ac832d0576f3e463" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yvR-0006r2-6h for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 15:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5yvD-0001AR-1R for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 15:59:43 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:53875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5yvC-0001A2-Lf for emacs-orgmode@gnu.org; Fri, 28 Sep 2018 15:59:30 -0400 Received: by mail-wm1-x336.google.com with SMTP id b19-v6so3347045wme.3 for ; Fri, 28 Sep 2018 12:59:30 -0700 (PDT) In-Reply-To: <8736tt77rb.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org-mode-email --000000000000ac832d0576f3e463 Content-Type: text/plain; charset="UTF-8" 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 wrote: > Hello, > > John Kitchin 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 > --000000000000ac832d0576f3e463 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
ok, tha= nks for confirming!

I tried a workaround like this:

#+BEGIN_SRC emacs-lisp -r
(defun my-tan= gle-with-r ()
=C2=A0 (interactive)
=C2=A0 (let* ((tempo= rary-file-directory ".")
(tmpname (make-temp-file "switch" nil ".org"= ))
buf
data)
=C2=A0 =C2=A0 (write-regi= on (point-min) (point-max) tmpname)
=C2=A0 =C2=A0 (setq buf (find= -file-noselect tmpname))
=C2=A0 =C2=A0 (with-current-buffer buf
=C2=A0 =C2=A0 =C2=A0 (setq data (org-element-parse-buffer))
<= div>=C2=A0 =C2=A0 =C2=A0 (org-element-map data 'src-block
(lambda (src)
=C2=A0 (org-element-put-property src :switches &q= uot;-r")))
=C2=A0 =C2=A0 =C2=A0 (erase-buffer)
=C2= =A0 =C2=A0 =C2=A0 (insert (org-element-interpret-data data))
=C2= =A0 =C2=A0 =C2=A0 (save-buffer)
=C2=A0 =C2=A0 =C2=A0 (org-babel-t= angle))
=C2=A0 =C2=A0 (kill-buffer buf)
=C2=A0 =C2=A0 (= delete-file tmpname)))
#+END_SRC

A= ny suggestions for improvement? It seems to work for me, but says it tangle= d from the temp file instead of the main file (that is expected, but not id= eal). I tried some simpler ways but with=C2=A0org-export-with-buffer-copy, = for example, I ran into difficulties because of the buffer modification, wh= ich I could find a way around that didn't lead to many copies of the bu= ffer being open. In this solution, I just save it and have no issue there.<= /div>

John

-----------------------= ------------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Depar= tment of Chemical Engineering
Carnegie Mellon University
Pittsburgh, = PA 15213
412-268-7803

<= /div>

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

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> I am working on a pretty large literate program right now, and am usin= g
> coderefs in the blocks. I know I can add a -r switch to a code block t= o
> 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 swi= tch?
> It isn't obvious that is possible, so I thought I would ask.

No, there is not.

Regards,

--
Nicolas Goaziou
--000000000000ac832d0576f3e463--