1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-27 07:37:25 +00:00

ob: canonical presentation of header arguments when hashing

* lisp/ob.el (org-babel-sha1-hash): Sort list values to header
  arguments, and sort the words in strings.
This commit is contained in:
Eric Schulte 2011-02-27 09:35:51 -07:00
parent 76137b16fa
commit dd31a84af6

View File

@ -711,22 +711,29 @@ the current subtree."
(setf (nth 2 info)
(sort (copy-sequence (nth 2 info))
(lambda (a b) (string< (car a) (car b)))))
(let ((hash (sha1
(format "%s-%s"
(mapconcat
#'identity
(delq nil
(mapcar
(lambda (arg)
(let ((v (cdr arg)))
(when (and v (not (and (sequencep v)
(not (consp v))
(= (length v) 0))))
(format "%S" v))))
(nth 2 info))) ":")
(nth 1 info)))))
(when (interactive-p) (message hash))
hash)))
((lambda (hash) (when (interactive-p) (message hash)) hash)
(sha1 (format "%s-%s"
(mapconcat
#'identity
(delq nil
(mapcar
(lambda (arg)
(let ((v (cdr arg)))
(when (and v (not (and (sequencep v)
(not (consp v))
(= (length v) 0))))
((lambda (el) (format "%S" el))
(cond
((and (listp v) ; lists are sorted
(member (car arg) '(:result-params)))
(sort v #'string<))
((and (stringp v) ; strings are sorted
(member (car arg) '(:results :exports)))
(mapconcat #'identity (sort (split-string v)
#'string<) " "))
(t v)))))) ; atomic are left untouched
(nth 2 info))) ":")
(nth 1 info))))))
(defun org-babel-result-hash (&optional info)
"Return the in-buffer hash associated with INFO."