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:
parent
76137b16fa
commit
dd31a84af6
39
lisp/ob.el
39
lisp/ob.el
|
@ -711,22 +711,29 @@ the current subtree."
|
||||||
(setf (nth 2 info)
|
(setf (nth 2 info)
|
||||||
(sort (copy-sequence (nth 2 info))
|
(sort (copy-sequence (nth 2 info))
|
||||||
(lambda (a b) (string< (car a) (car b)))))
|
(lambda (a b) (string< (car a) (car b)))))
|
||||||
(let ((hash (sha1
|
((lambda (hash) (when (interactive-p) (message hash)) hash)
|
||||||
(format "%s-%s"
|
(sha1 (format "%s-%s"
|
||||||
(mapconcat
|
(mapconcat
|
||||||
#'identity
|
#'identity
|
||||||
(delq nil
|
(delq nil
|
||||||
(mapcar
|
(mapcar
|
||||||
(lambda (arg)
|
(lambda (arg)
|
||||||
(let ((v (cdr arg)))
|
(let ((v (cdr arg)))
|
||||||
(when (and v (not (and (sequencep v)
|
(when (and v (not (and (sequencep v)
|
||||||
(not (consp v))
|
(not (consp v))
|
||||||
(= (length v) 0))))
|
(= (length v) 0))))
|
||||||
(format "%S" v))))
|
((lambda (el) (format "%S" el))
|
||||||
(nth 2 info))) ":")
|
(cond
|
||||||
(nth 1 info)))))
|
((and (listp v) ; lists are sorted
|
||||||
(when (interactive-p) (message hash))
|
(member (car arg) '(:result-params)))
|
||||||
hash)))
|
(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)
|
(defun org-babel-result-hash (&optional info)
|
||||||
"Return the in-buffer hash associated with INFO."
|
"Return the in-buffer hash associated with INFO."
|
||||||
|
|
Loading…
Reference in New Issue