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
This commit is contained in:
parent
cea9fd7421
commit
e905dbe0f6
23
lisp/ob.el
23
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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue