[O] Fwd: minor ob-sed.el patch for org-mode
Hello, This is a minor patch suggested by Brad Knotwell so that ob-sed can support BSD sed and not only GNU sed. Regards, Bjarte 0002-ob-sed-Use-f-instead-of-file-to-support-BSD-sed.patch Description: Binary data
Re: [O] Make ob-shell conform to the org-babel interface
Sorry for the delay. Is this better? 0001-ob-shell-Conform-to-variable-assignment-interface.patch Description: Binary data On 01 Jun 2015, at 19:18, Nicolas Goaziou m...@nicolasgoaziou.fr wrote: Hello, Bjarte Johansen bjarte.johan...@infomedia.uib.no writes: I found that ob-shell’s org-babel-variable-assignments:bash function does not respect the interface for org-babel. It takes multiple arguments when it should only take 1. This is a problem when f.ex. org-babel-sha1-hash tries to expand the body of a bash source block and tries to call that function with only 1 argument. I am not sure if the following patch follows best practices in the project, but it solves the problem for me. Thank you for the patch. Some comments follow. From 04f00e4f69c5352d51b7de1ba8783ddd96124c1f Mon Sep 17 00:00:00 2001 From: Bjarte Johansen bjarte.johan...@gmail.com Date: Wed, 27 May 2015 17:20:41 +0200 Subject: [PATCH] ob-shell: Conform to variable assignment interface You need to list modified functions in commit message. Change org-babel-variable-assignments functions in ob-shell to use the same function so conform to the interface used for variable assignment in org-babel. Org Babel +(ert-deftest test-ob-shell/should-respect-ob-interface-naming-convention () + Functions used to interface with the different org-babel + should have the correct signature. Org Babel. Also, do not indent second line, and please make first sentence fit on a single line. + (dolist (shell org-babel-shell-names) +(org-test-with-temp-text +(format #+BEGIN_SRCpoint %s :cache yes + echo test +#+END_SRC shell) + (let ((info (org-babel-get-src-block-info))) +(org-babel-sha1-hash info) You need to wrap this within a `should' in order to define a proper test. Regards, -- Nicolas Goaziou
Re: [O] ob-sed
On 30 May 2015, at 14:32, Nicolas Goaziou m...@nicolasgoaziou.fr wrote: Bjarte Johansen bjarte.johan...@infomedia.uib.no writes: I think I have addressed all of your comments except I didn’t understand the comment about the spaces. Are there two spaces extra or do you want me to introduce two spaces somewhere? As Suvayu Ali pointed out, sentences in comments and docstrings are expected to be separated by two spaces (american english convention). I was not aware of this convention. I also don’t really understand it, but I will change it. Also, is the following line +(require 'sed-mode) really needed? AFAICT there is no such mode in Emacs tree. No. It is not. I have removed it. 0001-Org-Babel-now-supports-sed-scripts.patch Description: Binary data
Re: [O] ob-sed
I think I have addressed all of your comments except I didn’t understand the comment about the spaces. Are there two spaces extra or do you want me to introduce two spaces somewhere? I have attached the updated patch. Regards, Bjarte 0001-Org-Babel-now-supports-sed-scripts.patch Description: Binary data On 29 May 2015, at 11:00, Nicolas Goaziou m...@nicolasgoaziou.fr wrote: Bjarte Johansen bjarte.johan...@infomedia.uib.no writes: I think I have addressed all your comments in the attached patch. Thank you. Some more comments follow. Subject: [PATCH] Org Babel now supports sed scripts You should add something like the following to your commit message: * doc/org.texi: Signal new Babel language * lisp/ob-sed.el: * testing/examples/ob-sed-test.org: * testing/lisp/test-ob-sed.el: New files. -@item GNU Screen @tab screen @tab shell @tab sh -@item SQL @tab sql @tab SQLite @tab sqlite +@item GNU Screen @tab screen Sed @tab sed +@item @tab shell @tab sh @item SQL @tab sql +@item @tab SQLite @tab sqlite @tab @tab This looks wrong. I think it should be: @item GNU Screen @tab screen @tab Sed @tab sed @item shell @tab sh @tab SQL @tab sql @item SQLite @tab sqlite @tab @tab +;;; Usage: + +;; Add to your Emacs config: + +;; (org-babel-do-load-languages +;; 'org-babel-load-languages +;; '((sed . t))) You may want to introduce usage for :cmd-line and :in-file arguments in Usage section. +(defconst org-babel-header-args:sed + '((:cmd-line :any + :in-file :any)) + Sed specific header arguments.) It should be '((:cmd-line . :any) (:in-file . :any)) See, for example `org-babel-header-args:R' +(defun org-babel-execute:sed (body params) + Execute a block of sed code with Org Babel. +BODY is the source inside a sed source block and PARAMS is an +association list over the source block configurations. This ^^^ two spaces Regards,
Re: [O] ob-sed
I think I have addressed all your comments in the attached patch. Regards, Bjarte 0001-Org-Babel-now-supports-sed-scripts.patch Description: Binary data
Re: [O] ob-sed
I had loosely based it on my own ob-sparql and ob-awk, I saw that there was a remnant of ob-sparql left in there. Here is an updated version. ob-sed.el Description: Binary data
[O] ob-sed
Hi, I originally wrote this for Eric Schulte’s sed-mode, but he thought I should post it here instead. I have been using it for little over a week and it has been working perfectly for me. If there is anything that you think should be added or removed before it is accepted into org-mode please tell me. I have already signed the CA for projects in relation to GNU Emacs. Regards, Bjarte ob-sed.el Description: Binary data
[O] Make ob-shell conform to the org-babel interface
Hi, I found that ob-shell’s org-babel-variable-assignments:bash function does not respect the interface for org-babel. It takes multiple arguments when it should only take 1. This is a problem when f.ex. org-babel-sha1-hash tries to expand the body of a bash source block and tries to call that function with only 1 argument. I am not sure if the following patch follows best practices in the project, but it solves the problem for me. 0001-ob-shell-Conform-to-variable-assignment-interface.patch Description: Binary data
[O] Stop conversion of result on serialising to file
When running a source block and storing the result in a file the data will first be converted to a table in org-babel-result-cond and then converted back to text when org-babel-execute-src-block writes it to file. This is takes a very long time when the result is big and it is unnecessary. I have attached a patch that makes org-babel-result-cond return the scalar result when it knows the result will be turned into a file. Regards, Bjarte 0001-ob-core-Do-not-return-results-on-writing-to-file.patch Description: Binary data
Re: [O] [PATCH] ob-core: Fix indented cached result returning nil
On 24 May 2015, at 11:53, Bjarte Johansen bjarte.johan...@gmail.com wrote: On 24 May 2015, at 11:49, Bjarte Johansen bjarte.johan...@gmail.com wrote: On 23 May 2015, at 21:50, Nicolas Goaziou m...@nicolasgoaziou.fr wrote: Bjarte Johansen bjarte.johan...@gmail.com writes: Fix a problem where a source block would return nil oif the result was cached and it was indented. Thank you. However, the test you provide fails. I suggest to create test.txt in `temporary-file-directory' instead of `default-directory'. Regards, Ah, it was not supposed to actually run the code in the source block; only get the cached result. I might know an easier test of it. I’ll send a revised version later. Actually, I saw now that it should be (message “test.txt”), notice the added extension. The hash is also therefore most likely wrong. I will fix it. No, this was wrong. I have a more robust fix and do as you suggest. Create the file in temporary-file-directory and run the execution of the source block twice to get the cache. This way, if org-mode changes its hashing function later, the test will still work. Sending the patch shortly. Regards, Bjarte
[O] [PATCH] ob-core: Fix indented cached result returning nil
Fix a problem where a source block would return nil oif the result was cached and it was indented. * lisp/ob-core.el (org-babel-execute-src-block): Move point to the the first character of the result instead of the beginning of the line. * testing/lisp/test-ob.el (test-org-babel/indented-cached-org-bracket-link): Added test to to see if the indented cached result returns what it should return. --- lisp/ob-core.el | 3 ++- testing/lisp/test-ob.el | 16 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index d25bb7c..9575096 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -653,7 +653,8 @@ block. (cache-current-p (save-excursion ;; return cached result (goto-char (org-babel-where-is-src-block-result nil info)) - (end-of-line 1) (forward-char 1) + (end-of-line 1) + (forward-char (1+ (current-indentation))) (let ((result (org-babel-read-result))) (message (replace-regexp-in-string % %% (format %S result))) result))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index f52ff24..83b4d00 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -20,6 +20,22 @@ ;;; Code: +(ert-deftest test-org-babel/indented-cached-org-bracket-link () + When the result of a source block is a cached indented link it +should still return the link. + (should + (let ((default-directory temporary-file-directory)) + (org-test-with-temp-text + +* Test + #+pointBEGIN_SRC emacs-lisp :file test.txt :cache yes +(message \test\) + #+END_SRC + ;; Execute twice as the first time creates the cache. + (org-babel-execute-src-block) + (string= (concat default-directory test.txt) + (org-babel-execute-src-block)) + (ert-deftest test-org-babel/multi-line-header-regexp () (should(equal ^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$ org-babel-multi-line-header-regexp)) -- 2.3.2 (Apple Git-55)
Re: [O] [PATCH] ob-core: Fix indented cached result returning nil
On 23 May 2015, at 21:50, Nicolas Goaziou m...@nicolasgoaziou.fr wrote: Bjarte Johansen bjarte.johan...@gmail.com writes: Fix a problem where a source block would return nil oif the result was cached and it was indented. Thank you. However, the test you provide fails. I suggest to create test.txt in `temporary-file-directory' instead of `default-directory'. Regards, Ah, it was not supposed to actually run the code in the source block; only get the cached result. I might know an easier test of it. I’ll send a revised version later.
Re: [O] [PATCH] ob-core: Fix indented cached result returning nil
On 24 May 2015, at 11:49, Bjarte Johansen bjarte.johan...@gmail.com wrote: On 23 May 2015, at 21:50, Nicolas Goaziou m...@nicolasgoaziou.fr wrote: Bjarte Johansen bjarte.johan...@gmail.com writes: Fix a problem where a source block would return nil oif the result was cached and it was indented. Thank you. However, the test you provide fails. I suggest to create test.txt in `temporary-file-directory' instead of `default-directory'. Regards, Ah, it was not supposed to actually run the code in the source block; only get the cached result. I might know an easier test of it. I’ll send a revised version later. Actually, I saw now that it should be (message “test.txt”), notice the added extension. The hash is also therefore most likely wrong. I will fix it.
[O] Using buffers instead of string when processing and passing org-babel results
Hi, I have been wondering: Is there a reason org-babel passes around results as strings instead of buffers? I understand there will be more to keep track of and right now there is a great chance of breaking code (org-modes code and other people who depend on the current behaviour). However, I just did an elementary test with the following #+BEGIN_SRC bash :results verbatim cat file.txt #+END_SRC I created the file with the command `base64 /dev/urandom | head -c 100M file.txt`. If I execute the script in the normal way it takes more then half a minute to complete. If I on the other hand convert every point on the path that expect it to be a string to be a buffer instead it takes less than 5 seconds to complete the script and insert the result into the buffer. I understand that it might not be normal to insert these big files into the org-buffer, but the problem is also there if you want to silence the result and pass it from script to script. The creation of big strings is really slow. I also feel that buffers are more natural vessels for the results. They are easier to manipulate than strings in Emacs and are much much faster. A big problem however is how do we handle the buffers that are created? They won’t be garage collected, so we need a way to safely kill them when we no longer need them. Is this something that org-mode is interested in? I could try to work on it, but if org-mode isn’t interested in the change I am not sure I will bother. Regards, Bjarte
[O] [PATCH] ob-core: Fix indented cached result returning nil
Fix a problem where a source block would return nil oif the result was cached and it was indented. * lisp/ob-core.el (org-babel-execute-src-block): Move point to the the first character of the result instead of the beginning of the line. * testing/lisp/test-ob.el (test-org-babel/indented-cached-org-bracket-link): Added test to to see if the indented cached result returns what it should return. --- lisp/ob-core.el | 3 ++- testing/lisp/test-ob.el | 16 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 91bbde4..1f21685 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -652,7 +652,8 @@ block. (cache-current-p (save-excursion ;; return cached result (goto-char (org-babel-where-is-src-block-result nil info)) - (end-of-line 1) (forward-char 1) + (end-of-line 1) + (forward-char (1+ (current-indentation))) (let ((result (org-babel-read-result))) (message (replace-regexp-in-string % %% (format %S result))) result))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index f52ff24..55b45ad 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -20,6 +20,22 @@ ;;; Code: +(ert-deftest test-org-babel/indented-cached-org-bracket-link () + When the result of a source block is a cached indented link it +should still return the link. + (should + (org-test-with-temp-text + +* Test + #+pointBEGIN_SRC emacs-lisp :file test.txt :cache yes +(message \test\) + #+END_SRC + + #+RESULTS[f82e11feb0f46907bc5a256a27e9dd81a3876d14]: + [[file:test.txt]] +(string= (concat default-directory test.txt) +(org-babel-execute-src-block) + (ert-deftest test-org-babel/multi-line-header-regexp () (should(equal ^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$ org-babel-multi-line-header-regexp)) -- 2.3.2 (Apple Git-55)
Re: [O] [PATCH] ob-core: Fix indented cached result returning nil
Thank you for your comments. You need to add TINYCHANGE at the end of the commit message if you haven't signed FSF papers yet. I have already signed the FSF papers when I sent some changes to a different Emacs project. I will shortly send a new patch with the proposed changes. Regards, Bjarte
[O] [PATCH] ob-core: Fix indented cached result returning nil
Fix a problem where a source block would return nil if the result was cached and it was indented. * lisp/ob-core.el (org-babel-execute-src-block): Move point to the the first character of the result instead of the beginning of the line. * testing/lisp/test-ob.el (test-org-babel/indented-cached-org-bracket-link): Added test to to see if the indented cached result returns what it should return. --- lisp/ob-core.el | 2 +- testing/lisp/test-ob.el | 17 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 91bbde4..e7e029d 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -652,7 +652,7 @@ block. (cache-current-p (save-excursion ;; return cached result (goto-char (org-babel-where-is-src-block-result nil info)) - (end-of-line 1) (forward-char 1) + (end-of-line 1) (forward-char (1+ (current-indentation))) (let ((result (org-babel-read-result))) (message (replace-regexp-in-string % %% (format %S result))) result))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index f52ff24..ae61b0c 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -20,6 +20,23 @@ ;;; Code: +(ert-deftest test-org-babel/indented-cached-org-bracket-link () + When the result of a source block is indentend, a link and +cached it should still return the link. + (let ((test-block (concat * Test\n + #+BEGIN_SRC sh :file test.txt :cache yes\n + echo 'text'\n + #+END_SRC\n + \n + #+RESULTS[be4fa2f590a6bc5b6c1f2a6747a067404506]:\n + [[file:test.txt]]))) +(with-temp-buffer + (insert test-block) + (search-backward BEGIN_SRC) + (org-mode) + (should (string= (concat default-directory test.txt) + (org-babel-execute-src-block)) + (ert-deftest test-org-babel/multi-line-header-regexp () (should(equal ^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$ org-babel-multi-line-header-regexp)) -- 2.3.2 (Apple Git-55)
Re: [O] org-babel for prolog
On 16 May 2015, at 15:31, Lawrence Bottorff borg...@gmail.com wrote: No worries. I can wait. Thanks again for your efforts. I had some spare time today that I didn’t expect. I believe I have fixed the bug. Kind regards, Bjarte
Re: [O] org-babel for prolog
On 14 May 2015, at 20:22, Puneeth Chaganti puncha...@gmail.com wrote: On Thu, May 14, 2015 at 11:41 PM, Lawrence Bottorff borg...@gmail.com wrote: Confused by the requirement: ;; To activate ob-prolog add the following to your init.el file: ;; ;; (eval-after-load 'org ;;'(require 'org-prolog)) I'm guessing its a typo and should be ob-prolog. The file provides ob-prolog. Yes, I typed it wrong. Thank you for bringing it to my attention. I also discovered that it is better to use `org-babel-do-load-languages’ instead as well. I will change the recommendation tomorrow. Regards, Bjarte
Re: [O] org-babel for prolog
I thought you should know that I moved the project here: https://github.com/ljos/ob-prolog https://github.com/ljos/ob-prolog This makes it a bit easier for me to track issues and do proper commit-messages etc. I have now implemented the session stuff properly (I think). I still have to implement the variable stuff and expansion of the body (or I can perhaps just use the generic function). 19. des. 2014 kl. 16.25 skrev Bjarte Johansen bjarte.johan...@infomedia.uib.no: I just wanted to report that it is now possible to evaluate prolog code and it should return the correct result. Both as a call to the executable and in a session. When calling a goal in a session, I add a cut at the end of the goal so that prolog doesn’t ask if you want to get the next possible answer. I am not sure if this is the best approach. I haven’t implemented variable assignment yet because I haven’t decided how it should do that considering how prolog uses variables. If someone has any ideas for this I would be glad to hear them. I have considered entering the variables into the prolog database with the record predicates or replacing all prolog variables with the same name as in the var declaration with the value. The last one I don’t think is a particularly good idea, except if we only replace the free variables. Regards, Bjarte 10. des. 2014 kl. 18.20 skrev Bjarte Johansen bjarte.johan...@infomedia.uib.no mailto:bjarte.johan...@infomedia.uib.no: Hi, I have started to implement org-babel support for (swi-)prolog. I have gotten to the point where I can execute a goal in an external process and have the result show up in the org file. I am now working on getting the session to work correctly. It runs and prints, but it doesn’t do the correct thing in the inferior-mode-buffer and the output is garbled. I still have some work ahead of me. I just thought I would let you know in case someone was interested in following the progress or maybe also in helping me. I have the mode hosted in its current state here https://gist.github.com/ljos/2e346333e1b7bfd56d05 https://gist.github.com/ljos/2e346333e1b7bfd56d05 . And before you ask, yes, if I get this into a working order, I would eventually be interested in getting this into either contrib or core. Regards, Bjarte
Re: [O] org-babel for prolog
I just wanted to report that it is now possible to evaluate prolog code and it should return the correct result. Both as a call to the executable and in a session. When calling a goal in a session, I add a cut at the end of the goal so that prolog doesn’t ask if you want to get the next possible answer. I am not sure if this is the best approach. I haven’t implemented variable assignment yet because I haven’t decided how it should do that considering how prolog uses variables. If someone has any ideas for this I would be glad to hear them. I have considered entering the variables into the prolog database with the record predicates or replacing all prolog variables with the same name as in the var declaration with the value. The last one I don’t think is a particularly good idea, except if we only replace the free variables. Regards, Bjarte 10. des. 2014 kl. 18.20 skrev Bjarte Johansen bjarte.johan...@infomedia.uib.no: Hi, I have started to implement org-babel support for (swi-)prolog. I have gotten to the point where I can execute a goal in an external process and have the result show up in the org file. I am now working on getting the session to work correctly. It runs and prints, but it doesn’t do the correct thing in the inferior-mode-buffer and the output is garbled. I still have some work ahead of me. I just thought I would let you know in case someone was interested in following the progress or maybe also in helping me. I have the mode hosted in its current state here https://gist.github.com/ljos/2e346333e1b7bfd56d05 https://gist.github.com/ljos/2e346333e1b7bfd56d05 . And before you ask, yes, if I get this into a working order, I would eventually be interested in getting this into either contrib or core. Regards, Bjarte
[O] org-babel for prolog
Hi, I have started to implement org-babel support for (swi-)prolog. I have gotten to the point where I can execute a goal in an external process and have the result show up in the org file. I am now working on getting the session to work correctly. It runs and prints, but it doesn’t do the correct thing in the inferior-mode-buffer and the output is garbled. I still have some work ahead of me. I just thought I would let you know in case someone was interested in following the progress or maybe also in helping me. I have the mode hosted in its current state here https://gist.github.com/ljos/2e346333e1b7bfd56d05 https://gist.github.com/ljos/2e346333e1b7bfd56d05 . And before you ask, yes, if I get this into a working order, I would eventually be interested in getting this into either contrib or core. Regards, Bjarte