summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2011-02-27 09:35:51 -0700
committerEric Schulte <schulte.eric@gmail.com>2011-02-27 09:40:35 -0700
commitdd31a84af65dfcadb8d334ea0d92c24d86fd9491 (patch)
tree7e90f62e7cf75ed5f7b5e87e258024781588995c
parent76137b16fa694204cc1e1225744dac15bb96e380 (diff)
downloadorg-mode-dd31a84af65dfcadb8d334ea0d92c24d86fd9491.tar.gz
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.
-rw-r--r--lisp/ob.el39
1 files changed, 23 insertions, 16 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index 6e98263..18cae37 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -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."