From e905dbe0f60e2326061c63621e603f5b396373a1 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sat, 16 Oct 2010 13:55:54 -0600 Subject: [PATCH] babel hashing now handles more complex types in params * lisp/ob.el (org-babel-sha1-hash): now handles more complex types in params * testing/examples/babel.org: whitespace * testing/lisp/test-ob.el (test-org-babel/sha1-hash): new test for babel hashing --- lisp/ob.el | 23 +++++++++++++++-------- testing/examples/babel.org | 2 ++ testing/lisp/test-ob.el | 6 ++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index b2c2464b7..32422f129 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -609,17 +609,24 @@ the current subtree." (defun org-babel-sha1-hash (&optional info) "Generate an sha1 hash based on the value of info." (interactive) - (let* ((info (or info (org-babel-get-src-block-info))) + (let* ((print-level nil) + (info (or info (org-babel-get-src-block-info))) (hash (sha1 (format "%s-%s" (mapconcat - (lambda (arg) - (if (stringp (cdr arg)) - (mapconcat - #'identity - (sort (split-string (cdr arg)) #'string<) " ") - (cdr arg))) - (nth 2 info) ":") + #'identity + (delq nil + (mapcar + (lambda (arg) + (let ((v (cdr arg))) + (when (and v (not (and (sequencep v) + (> (length v) 0)))) + (if (stringp v) + (mapconcat #'identity + (sort (split-string v) + #'string<) " ") + (format "%S" v))))) + (nth 2 info))) ":") (nth 1 info))))) (when (interactive-p) (message hash)) hash)) diff --git a/testing/examples/babel.org b/testing/examples/babel.org index f42c3b25f..e367aea6b 100644 --- a/testing/examples/babel.org +++ b/testing/examples/babel.org @@ -129,6 +129,7 @@ (pascals-triangle n) #+end_src + * calling code blocks from inside table :PROPERTIES: :ID: 6d2ff4ce-4489-4e2a-9c65-e3f71f77d975 @@ -138,6 +139,7 @@ #+begin_src emacs-lisp :var n=9 (sqrt n) #+end_src + * executing an lob call line :PROPERTIES: :results: silent diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 2ee44c884..b6e48d9ff 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -64,6 +64,12 @@ (should (equal 'a (cadr (assoc 1 results)))) (should (equal 'd (cadr (assoc 4 results))))))) +(ert-deftest test-org-babel/sha1-hash () + (org-test-at-id "f68821bc-7f49-4389-85b5-914791ee3718" + (org-babel-next-src-block 2) + (should (string= "615946d1cd30c88c17ae6bf1d56a3f90232ddf78" + (org-babel-sha1-hash))))) + (provide 'test-ob) ;;; test-ob ends here \ No newline at end of file