* ist here a :post header arg for tangling? @ 2021-01-01 1:08 George Mauer 2021-01-01 12:29 ` Immanuel Litzroth 0 siblings, 1 reply; 9+ messages in thread From: George Mauer @ 2021-01-01 1:08 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 104 bytes --] I'd like to run some code to post-process files after they are tangled. Is there a header-arg for that? [-- Attachment #2: Type: text/html, Size: 129 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-01 1:08 ist here a :post header arg for tangling? George Mauer @ 2021-01-01 12:29 ` Immanuel Litzroth 2021-01-04 14:07 ` Diego Zamboni 2021-01-04 15:28 ` George Mauer 0 siblings, 2 replies; 9+ messages in thread From: Immanuel Litzroth @ 2021-01-01 12:29 UTC (permalink / raw) To: gmauer; +Cc: emacs-orgmode I don't think there is an arg for that. I have written a tangler that reuses a lot of the org-babel machinery and has a more flexible mechanism to decide what to do with the tangled code -- I use it for example to not write a tangled file if it hasn't changed, meaning that it will not trigger recompile. The project is private now but if you're interested I can give you access to it. What exactly are you trying to do? Immanuel On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: > > I'd like to run some code to post-process files after they are tangled. Is there a header-arg for that? -- -- Researching the dual problem of finding the function that has a given point as fixpoint. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-01 12:29 ` Immanuel Litzroth @ 2021-01-04 14:07 ` Diego Zamboni 2021-01-04 14:50 ` Immanuel Litzroth 2021-01-04 15:28 ` George Mauer 1 sibling, 1 reply; 9+ messages in thread From: Diego Zamboni @ 2021-01-04 14:07 UTC (permalink / raw) To: Immanuel Litzroth; +Cc: gmauer, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1115 bytes --] There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that will be run with the tangled code in a temporary buffer. I couldn't find much documentation nor examples, but it is mentioned at https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3 --Diego On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth < immanuel.litzroth@gmail.com> wrote: > I don't think there is an arg for that. I have written a tangler that > reuses a lot > of the org-babel machinery and has a more flexible mechanism to decide what > to do with the tangled code -- I use it for example to not write a > tangled file if it > hasn't changed, meaning that it will not trigger recompile. > The project is private now but if you're interested I can give you access > to it. > What exactly are you trying to do? > Immanuel > > On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: > > > > I'd like to run some code to post-process files after they are tangled. > Is there a header-arg for that? > > > > -- > -- Researching the dual problem of finding the function that has a > given point as fixpoint. > > [-- Attachment #2: Type: text/html, Size: 1787 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-04 14:07 ` Diego Zamboni @ 2021-01-04 14:50 ` Immanuel Litzroth 2021-01-04 15:10 ` Diego Zamboni 0 siblings, 1 reply; 9+ messages in thread From: Immanuel Litzroth @ 2021-01-04 14:50 UTC (permalink / raw) To: Diego Zamboni; +Cc: gmauer, emacs-orgmode There's that, but you're not gonna do much with that since it is global to emacs. If you're brimming with vigour you might achieve what you want by rebinding that each time you tangle to do the correct thing. Not much information is available in that hook, you get dropped into a temp buffer containing the result of tangling. Immanuel On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni <diego@zzamboni.org> wrote: > > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that will be run with the tangled code in a temporary buffer. I couldn't find much documentation nor examples, but it is mentioned at https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3 > > --Diego > > > > > > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: >> >> I don't think there is an arg for that. I have written a tangler that >> reuses a lot >> of the org-babel machinery and has a more flexible mechanism to decide what >> to do with the tangled code -- I use it for example to not write a >> tangled file if it >> hasn't changed, meaning that it will not trigger recompile. >> The project is private now but if you're interested I can give you access to it. >> What exactly are you trying to do? >> Immanuel >> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: >> > >> > I'd like to run some code to post-process files after they are tangled. Is there a header-arg for that? >> >> >> >> -- >> -- Researching the dual problem of finding the function that has a >> given point as fixpoint. >> -- -- Researching the dual problem of finding the function that has a given point as fixpoint. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-04 14:50 ` Immanuel Litzroth @ 2021-01-04 15:10 ` Diego Zamboni 2021-01-04 15:31 ` Immanuel Litzroth 2021-01-04 15:38 ` Immanuel Litzroth 0 siblings, 2 replies; 9+ messages in thread From: Diego Zamboni @ 2021-01-04 15:10 UTC (permalink / raw) To: Immanuel Litzroth; +Cc: gmauer, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2003 bytes --] Agree. It should be possible to make the hook file-local, but still it's not trivial to have good control over where and how the changes are made. --Diego On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth < immanuel.litzroth@gmail.com> wrote: > There's that, but you're not gonna do much with that since it is > global to emacs. If you're brimming > with vigour you might achieve what you want by rebinding that each > time you tangle to do the correct > thing. Not much information is available in that hook, you get dropped > into a temp buffer containing the > result of tangling. > Immanuel > > On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni <diego@zzamboni.org> wrote: > > > > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that > will be run with the tangled code in a temporary buffer. I couldn't find > much documentation nor examples, but it is mentioned at > https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3 > > > > --Diego > > > > > > > > > > > > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth < > immanuel.litzroth@gmail.com> wrote: > >> > >> I don't think there is an arg for that. I have written a tangler that > >> reuses a lot > >> of the org-babel machinery and has a more flexible mechanism to decide > what > >> to do with the tangled code -- I use it for example to not write a > >> tangled file if it > >> hasn't changed, meaning that it will not trigger recompile. > >> The project is private now but if you're interested I can give you > access to it. > >> What exactly are you trying to do? > >> Immanuel > >> > >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: > >> > > >> > I'd like to run some code to post-process files after they are > tangled. Is there a header-arg for that? > >> > >> > >> > >> -- > >> -- Researching the dual problem of finding the function that has a > >> given point as fixpoint. > >> > > > -- > -- Researching the dual problem of finding the function that has a > given point as fixpoint. > [-- Attachment #2: Type: text/html, Size: 2988 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-04 15:10 ` Diego Zamboni @ 2021-01-04 15:31 ` Immanuel Litzroth 2021-01-04 15:36 ` Immanuel Litzroth 2021-01-04 15:38 ` Immanuel Litzroth 1 sibling, 1 reply; 9+ messages in thread From: Immanuel Litzroth @ 2021-01-04 15:31 UTC (permalink / raw) To: Diego Zamboni; +Cc: gmauer, emacs-orgmode Well I solved the problem by writing a tangler which can be configured with tangle-config you define a tangler by making a hash "language" -> tangle-hooks. The tangle-hooks are called at beginning of tangling, on each source block, on each noweb-ref and at the end of tangling. They receive the full source-block-info to do their work, and in the case of noweb-references they receive the full stack of sbi's that lead up to this noweb reference. >>> (tangled-buffer "Buffer that is being tangled") (name "Name of the code block") (tangle-file "Filename to tangle to") (properties "Properties of this block") (full-block "Text of the full block") (beg-block "Buffer pos of beginning of the block in the tangled buffer") (end-block "end of the block in the tangled buffer") (lang "language of the tangled buffer") (beg-lang "beginning of the language in the tangled buffer") (end-lang "end of the language in the tangled buffer") (switches "switches of this block") (beg-switches "begin of the switches in this block") (end-switches "end of the switches in this block") (header-args "header args of this block") (beg-header-args "buffer pos of header args beginning") (end-header-args "buffer pos of header args end") (body "body of the tangled block") (beg-body "buffer pos of the beginning of the body") (end-body "buffer pos of the end of the body")) >>> That way I can tangle a multi language org file and do the correct thing for each of the language by defining functions of interest. It's quite flexible, I'm going to use it to do some aspect-oriented programming/tangling when I find the time. Immanuel On Mon, Jan 4, 2021 at 4:11 PM Diego Zamboni <diego@zzamboni.org> wrote: > > Agree. It should be possible to make the hook file-local, but still it's not trivial to have good control over where and how the changes are made. > > --Diego > > > On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: >> >> There's that, but you're not gonna do much with that since it is >> global to emacs. If you're brimming >> with vigour you might achieve what you want by rebinding that each >> time you tangle to do the correct >> thing. Not much information is available in that hook, you get dropped >> into a temp buffer containing the >> result of tangling. >> Immanuel >> >> On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni <diego@zzamboni.org> wrote: >> > >> > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that will be run with the tangled code in a temporary buffer. I couldn't find much documentation nor examples, but it is mentioned at https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3 >> > >> > --Diego >> > >> > >> > >> > >> > >> > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: >> >> >> >> I don't think there is an arg for that. I have written a tangler that >> >> reuses a lot >> >> of the org-babel machinery and has a more flexible mechanism to decide what >> >> to do with the tangled code -- I use it for example to not write a >> >> tangled file if it >> >> hasn't changed, meaning that it will not trigger recompile. >> >> The project is private now but if you're interested I can give you access to it. >> >> What exactly are you trying to do? >> >> Immanuel >> >> >> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: >> >> > >> >> > I'd like to run some code to post-process files after they are tangled. Is there a header-arg for that? >> >> >> >> >> >> >> >> -- >> >> -- Researching the dual problem of finding the function that has a >> >> given point as fixpoint. >> >> >> >> >> -- >> -- Researching the dual problem of finding the function that has a >> given point as fixpoint. -- -- Researching the dual problem of finding the function that has a given point as fixpoint. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-04 15:31 ` Immanuel Litzroth @ 2021-01-04 15:36 ` Immanuel Litzroth 0 siblings, 0 replies; 9+ messages in thread From: Immanuel Litzroth @ 2021-01-04 15:36 UTC (permalink / raw) To: Diego Zamboni; +Cc: gmauer, emacs-orgmode Oh and I also made the tangling itself more flexible in that you can now also choose to only tangle stuff going to a certain file. This is mainly to be able to define an interactive command that tangles/reloads everything going to the file under point. Immanuel On Mon, Jan 4, 2021 at 4:31 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: > > Well I solved the problem by writing a tangler which can be configured > with tangle-config > you define a tangler by making a hash "language" -> tangle-hooks. The > tangle-hooks are > called at beginning of tangling, on each source block, on each > noweb-ref and at the end of > tangling. They receive the full source-block-info to do their work, > and in the case of noweb-references > they receive the full stack of sbi's that lead up to this noweb reference. > >>> > (tangled-buffer "Buffer that is being tangled") > (name "Name of the code block") > (tangle-file "Filename to tangle to") > (properties "Properties of this block") > (full-block "Text of the full block") > (beg-block "Buffer pos of beginning of the block in the tangled buffer") > (end-block "end of the block in the tangled buffer") > (lang "language of the tangled buffer") > (beg-lang "beginning of the language in the tangled buffer") > (end-lang "end of the language in the tangled buffer") > (switches "switches of this block") > (beg-switches "begin of the switches in this block") > (end-switches "end of the switches in this block") > (header-args "header args of this block") > (beg-header-args "buffer pos of header args beginning") > (end-header-args "buffer pos of header args end") > (body "body of the tangled block") > (beg-body "buffer pos of the beginning of the body") > (end-body "buffer pos of the end of the body")) > >>> > That way I can tangle a multi language org file and do the correct thing for > each of the language by defining functions of interest. It's quite > flexible, I'm > going to use it to do some aspect-oriented programming/tangling when I > find the time. > Immanuel > > On Mon, Jan 4, 2021 at 4:11 PM Diego Zamboni <diego@zzamboni.org> wrote: > > > > Agree. It should be possible to make the hook file-local, but still it's not trivial to have good control over where and how the changes are made. > > > > --Diego > > > > > > On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: > >> > >> There's that, but you're not gonna do much with that since it is > >> global to emacs. If you're brimming > >> with vigour you might achieve what you want by rebinding that each > >> time you tangle to do the correct > >> thing. Not much information is available in that hook, you get dropped > >> into a temp buffer containing the > >> result of tangling. > >> Immanuel > >> > >> On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni <diego@zzamboni.org> wrote: > >> > > >> > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that will be run with the tangled code in a temporary buffer. I couldn't find much documentation nor examples, but it is mentioned at https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3 > >> > > >> > --Diego > >> > > >> > > >> > > >> > > >> > > >> > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: > >> >> > >> >> I don't think there is an arg for that. I have written a tangler that > >> >> reuses a lot > >> >> of the org-babel machinery and has a more flexible mechanism to decide what > >> >> to do with the tangled code -- I use it for example to not write a > >> >> tangled file if it > >> >> hasn't changed, meaning that it will not trigger recompile. > >> >> The project is private now but if you're interested I can give you access to it. > >> >> What exactly are you trying to do? > >> >> Immanuel > >> >> > >> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: > >> >> > > >> >> > I'd like to run some code to post-process files after they are tangled. Is there a header-arg for that? > >> >> > >> >> > >> >> > >> >> -- > >> >> -- Researching the dual problem of finding the function that has a > >> >> given point as fixpoint. > >> >> > >> > >> > >> -- > >> -- Researching the dual problem of finding the function that has a > >> given point as fixpoint. > > > > -- > -- Researching the dual problem of finding the function that has a > given point as fixpoint. -- -- Researching the dual problem of finding the function that has a given point as fixpoint. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-04 15:10 ` Diego Zamboni 2021-01-04 15:31 ` Immanuel Litzroth @ 2021-01-04 15:38 ` Immanuel Litzroth 1 sibling, 0 replies; 9+ messages in thread From: Immanuel Litzroth @ 2021-01-04 15:38 UTC (permalink / raw) To: Diego Zamboni; +Cc: gmauer, emacs-orgmode I also seem to remember that the buffer you are dropped into after tangling doesn't even have the correct major mode set. Immanuel On Mon, Jan 4, 2021 at 4:11 PM Diego Zamboni <diego@zzamboni.org> wrote: > > Agree. It should be possible to make the hook file-local, but still it's not trivial to have good control over where and how the changes are made. > > --Diego > > > On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: >> >> There's that, but you're not gonna do much with that since it is >> global to emacs. If you're brimming >> with vigour you might achieve what you want by rebinding that each >> time you tangle to do the correct >> thing. Not much information is available in that hook, you get dropped >> into a temp buffer containing the >> result of tangling. >> Immanuel >> >> On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni <diego@zzamboni.org> wrote: >> > >> > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that will be run with the tangled code in a temporary buffer. I couldn't find much documentation nor examples, but it is mentioned at https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3 >> > >> > --Diego >> > >> > >> > >> > >> > >> > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: >> >> >> >> I don't think there is an arg for that. I have written a tangler that >> >> reuses a lot >> >> of the org-babel machinery and has a more flexible mechanism to decide what >> >> to do with the tangled code -- I use it for example to not write a >> >> tangled file if it >> >> hasn't changed, meaning that it will not trigger recompile. >> >> The project is private now but if you're interested I can give you access to it. >> >> What exactly are you trying to do? >> >> Immanuel >> >> >> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: >> >> > >> >> > I'd like to run some code to post-process files after they are tangled. Is there a header-arg for that? >> >> >> >> >> >> >> >> -- >> >> -- Researching the dual problem of finding the function that has a >> >> given point as fixpoint. >> >> >> >> >> -- >> -- Researching the dual problem of finding the function that has a >> given point as fixpoint. -- -- Researching the dual problem of finding the function that has a given point as fixpoint. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ist here a :post header arg for tangling? 2021-01-01 12:29 ` Immanuel Litzroth 2021-01-04 14:07 ` Diego Zamboni @ 2021-01-04 15:28 ` George Mauer 1 sibling, 0 replies; 9+ messages in thread From: George Mauer @ 2021-01-04 15:28 UTC (permalink / raw) To: Immanuel Litzroth; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1359 bytes --] So like I said, I would like to run some code to post-process files. Nothing super-concrete, but a bunch of small use cases I've run into such as - Running tests on every tangle - Executing a code block in the same document and running tests after all tangles - Running a code-formatter such as prettierjs (or the python one which name escapes me - autopep?) and potentially de-tangling back I realize some of these things I could do with a file watcher, but not really the ones that require modifying the document again On Fri, Jan 1, 2021 at 6:29 AM Immanuel Litzroth < immanuel.litzroth@gmail.com> wrote: > I don't think there is an arg for that. I have written a tangler that > reuses a lot > of the org-babel machinery and has a more flexible mechanism to decide what > to do with the tangled code -- I use it for example to not write a > tangled file if it > hasn't changed, meaning that it will not trigger recompile. > The project is private now but if you're interested I can give you access > to it. > What exactly are you trying to do? > Immanuel > > On Fri, Jan 1, 2021 at 2:09 AM George Mauer <gmauer@gmail.com> wrote: > > > > I'd like to run some code to post-process files after they are tangled. > Is there a header-arg for that? > > > > -- > -- Researching the dual problem of finding the function that has a > given point as fixpoint. > [-- Attachment #2: Type: text/html, Size: 1898 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-01-04 15:39 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-01-01 1:08 ist here a :post header arg for tangling? George Mauer 2021-01-01 12:29 ` Immanuel Litzroth 2021-01-04 14:07 ` Diego Zamboni 2021-01-04 14:50 ` Immanuel Litzroth 2021-01-04 15:10 ` Diego Zamboni 2021-01-04 15:31 ` Immanuel Litzroth 2021-01-04 15:36 ` Immanuel Litzroth 2021-01-04 15:38 ` Immanuel Litzroth 2021-01-04 15:28 ` George Mauer
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).