[Orgmode] Re: [babel] apply #+TABLEFM lines during export?
On Tue, Jul 13 2010, Eric Schulte wrote: if you want to use my approach above more widely you could name the code block say #+source:less-precision, then add :exports none to each of your existing code blocks that output over-precise data, and for each such block add a call of the following form #+call: less-precision(tab=overly-precise-R-block) :exports results which should work, but would litter your file with these call lines. I guess this is an instance where a post-processing function specified at the file/subtree level could potentially be useful. Yes, the post-processing approach really seems appropriate here-- looking forward to seeing what you come up with. In the mean time, is there definitely not any hook that applies a) during export, and b) after results are generated from source blocks? If not, is it possible that adding a hook like org-post-execution-pre-export-hook would be a reasonable suggestion? Carsten, thoughts? Thanks, /au -- Austin Frank http://aufrank.net GPG Public Key (D7398C2F): http://aufrank.net/personal.asc pgpH7G6Cm64uU.pgp Description: PGP signature ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [babel] apply #+TABLEFM lines during export?
On Sun, Jul 11 2010, Eric Schulte wrote: Under the current setup, I don't know of a way to ensure that the formula will be re-run. This may be a good place for future (post-feature-freeze) functionality. There has also been discussion of adding a header argument for post-processing code blocks which could accept the output of the evaluated code block as input -- this might be related. Yes, eager to see where this goes. As a work-around, I would suggest the following emacs-lisp code block. Export of this code block will trigger the evaluation of the R code block, and it will then trim the output of said block resulting in the desired table precision. #+begin_src emacs-lisp :var tab=anova-example :colnames yes :cache yes (mapcar (lambda (row) (mapcar (lambda (cell) (if (numberp cell) (format %.4f cell) cell)) row)) tab) #+end_src I tried to customize your approach to apply to the whole buffer. This code seems to do a nice job of changing the appearance of the tables within the buffer, but the extra precision is still maintained on export. --8---cut here---start-8--- #+source: format-table-floats #+BEGIN_SRC emacs-lisp :results silent :exports none (add-hook 'org-export-preprocess-final-hook (lambda () (while (re-search-forward |?[ ]+\\(-?[0-9]+\\.[0-9]+\\)\\(e-\\)?[ ]+| nil t) (progn (replace-match (concat (format %.4f (string-to-number (match-string 1))) |)) (org-table-align) #+END_SRC --8---cut here---end---8--- Can anyone suggest another approach that would change the precision of floats in all tables in the buffer before export? Perhaps there's a different hook I should be using for LaTeX export? Thanks! /au -- Austin Frank http://aufrank.net GPG Public Key (D7398C2F): http://aufrank.net/personal.asc pgpUqQ9qISTMi.pgp Description: PGP signature ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Re: [babel] apply #+TABLEFM lines during export?
Austin Frank austin.fr...@gmail.com writes: On Sun, Jul 11 2010, Eric Schulte wrote: Under the current setup, I don't know of a way to ensure that the formula will be re-run. This may be a good place for future (post-feature-freeze) functionality. There has also been discussion of adding a header argument for post-processing code blocks which could accept the output of the evaluated code block as input -- this might be related. Yes, eager to see where this goes. As a work-around, I would suggest the following emacs-lisp code block. Export of this code block will trigger the evaluation of the R code block, and it will then trim the output of said block resulting in the desired table precision. #+begin_src emacs-lisp :var tab=anova-example :colnames yes :cache yes (mapcar (lambda (row) (mapcar (lambda (cell) (if (numberp cell) (format %.4f cell) cell)) row)) tab) #+end_src I tried to customize your approach to apply to the whole buffer. This code seems to do a nice job of changing the appearance of the tables within the buffer, but the extra precision is still maintained on export. if you want to use my approach above more widely you could name the code block say #+source:less-precision, then add :exports none to each of your existing code blocks that output over-precise data, and for each such block add a call of the following form #+call: less-precision(tab=overly-precise-R-block) :exports results which should work, but would litter your file with these call lines. I guess this is an instance where a post-processing function specified at the file/subtree level could potentially be useful. Cheers -- Eric #+source: format-table-floats #+BEGIN_SRC emacs-lisp :results silent :exports none (add-hook 'org-export-preprocess-final-hook (lambda () (while (re-search-forward |?[ ]+\\(-?[0-9]+\\.[0-9]+\\)\\(e-\\)?[ ]+| nil t) (progn (replace-match (concat (format %.4f (string-to-number (match-string 1))) |)) (org-table-align) #+END_SRC Can anyone suggest another approach that would change the precision of floats in all tables in the buffer before export? Perhaps there's a different hook I should be using for LaTeX export? Thanks! /au ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode