summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornrichard (geodiff-mac3) <nrichard@ulb.ac.be>2012-12-06 15:38:44 (GMT)
committer Eric Schulte <eric.schulte@gmx.com>2012-12-07 19:41:53 (GMT)
commit2f9ddaf69981f334812ca4ae32600afdcdaa6aa7 (patch)
tree78b1d562e423d17ae07b20b0989b57526aea0357
parent29117be8b2d5f41164b0e2239350913146288bf0 (diff)
downloadorg-mode-2f9ddaf69981f334812ca4ae32600afdcdaa6aa7.zip
org-mode-2f9ddaf69981f334812ca4ae32600afdcdaa6aa7.tar.gz
ob: Fix org-babel-edit-distance for insertion/deletion
* lisp/ob.el (org-babel-edit-distance): When insertion or deletion are needed, make sure the distance is incremented. In addition, the now obsolete mmin function was removed.
-rw-r--r--lisp/ob.el15
1 files changed, 9 insertions, 6 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index c030a7f..0aba523 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -629,16 +629,19 @@ arguments and pop open the results in a preview buffer."
(l2 (length s2))
(dist (vconcat (mapcar (lambda (_) (make-vector (1+ l2) nil))
(number-sequence 1 (1+ l1)))))
- (in (lambda (i j) (aref (aref dist i) j)))
- (mmin (lambda (&rest lst) (apply #'min (remove nil lst)))))
+ (in (lambda (i j) (aref (aref dist i) j))))
(setf (aref (aref dist 0) 0) 0)
+ (dolist (j (number-sequence 1 l2))
+ (setf (aref (aref dist 0) j) j))
(dolist (i (number-sequence 1 l1))
+ (setf (aref (aref dist i) 0) i)
(dolist (j (number-sequence 1 l2))
(setf (aref (aref dist i) j)
- (+ (if (equal (aref s1 (1- i)) (aref s2 (1- j))) 0 1)
- (funcall mmin (funcall in (1- i) j)
- (funcall in i (1- j))
- (funcall in (1- i) (1- j)))))))
+ (min
+ (1+ (funcall in (1- i) j))
+ (1+ (funcall in i (1- j)))
+ (+ (if (equal (aref s1 (1- i)) (aref s2 (1- j))) 0 1)
+ (funcall in (1- i) (1- j)))))))
(funcall in l1 l2)))
(defun org-babel-combine-header-arg-lists (original &rest others)