anchor.diff:                                            nil))))
            (line-offset point 0 end))))))
   
  -(defun tm-find-ahead-results (results)
  -  (let ((min)
  -        (best))
  -    (loop :for result :in results
  -          :do (when (and result (or (null min) (> min (tm-result-start result))))
  -                (setf min (tm-result-start result))
  -                (setf best result)))
  -    best))
  -
  -(defun tm-recompute-results (results string i)
  -  (loop :for rest-results :on results
  -        :for result := (car rest-results)
  -        :do (when (and result
  -                       (>= i (tm-result-start result)))
  -              (let ((new-result
  -                     (tm-ahead-match (tm-result-syntax result)
  -                                     (tm-ahead-matcher (tm-result-syntax result))
  -                                     string
  -                                     i)))
  -                (setf (car rest-results)
  -                      new-result)))))
  -
   (defun tm-continue-prev-line (point)
     (let* ((line (point-line point))
            (prev (line-prev line))
  
positive.code: (defun tm-syntax-scan-line (point)
    (tm-continue-prev-line point)
    (let ((results
           (loop :for syntax :in (syntax-table-patterns (current-syntax))
                 :for result := (tm-ahead-match syntax
                                                (tm-ahead-matcher syntax)
                                                (line-string point)
                                                (point-charpos point))
                 :when result
                 :collect result)))
      (loop :for best := (tm-find-ahead-results results)
            :while best :do
            (tm-apply-result point best)
            (tm-recompute-results results
                                  (line-string point)
                                  (point-charpos point))))
    (line-offset point 1))
  
  (defun tm-syntax-scan-region (start end)
  
negative.code: (defun tm-result-reg-starts (result) (aref result 3))
  (defun tm-result-reg-ends   (result) (aref result 4))
  
  (defun tm-result= (result1 result2)
    (and (eq (tm-result-syntax result1)
             (tm-result-syntax result2))
         (= (tm-result-start result1)
            (tm-result-start result2))
         (= (tm-result-end result1)
            (tm-result-end result2))
         (equal (tm-result-reg-starts result1)
                (tm-result-reg-starts result2))
         (equal (tm-result-reg-ends result1)
                (tm-result-reg-ends result2))))
  
  (defun tm-get-results-from-patterns (patterns string start)
    (loop :for syntax :in patterns
          :for result := (tm-ahead-match syntax (tm-ahead-matcher syntax) string start)
          :when result
          :collect result))
  
  (defun tm-best-result (results)
    (let ((min)
          (best))
      (loop :for result :in results
            :do (when (and result (or (null min) (> min (tm-result-start result))))
                  (setf min (tm-result-start result))
                  (setf best result)))
      best))
  
  (defun tm-recompute-results (results string i)
    (loop :for rest-results :on results
          :for result := (car rest-results)
          :do (when (and result
                         (>= i (tm-result-start result)))
                (let ((new-result
                       (tm-ahead-match (tm-result-syntax result)
                                       (tm-ahead-matcher (tm-result-syntax result))
                                       string
                                       i)))
                  (setf (car rest-results)
                        new-result)))))
  
  (defun tm-apply-region (syntax point begin-result)
    (let ((start1 (if begin-result (tm-result-start begin-result) 0))
          (start2 (if begin-result (tm-result-end begin-result) 0)))
      (let* ((end-result
              (tm-ahead-match syntax
                              (syntax-region-end syntax)
                              (line-string point)
                              start2))
             (results
              (cons end-result
                    (tm-get-results-from-patterns (syntax-region-patterns syntax)
                                                  (line-string point)
                                                  start2))))
        (loop :for $count :from 0 :do
          (let ((best (tm-best-result results)))
            (cond ((null end-result)
                   (line-add-property (point-line point)
                                      start1
                                      (line-length (point-line point))
                                      :attribute (syntax-attribute syntax)
                                      t)
                   (set-syntax-context (point-line point) syntax)
                   (line-end point)
                   (return))
                  ((tm-result= best end-result)
                   (line-add-property (point-line point)
                                      start1
                                      (tm-result-end end-result)
                                      :attribute (syntax-attribute syntax)
                                      nil)
                   (line-offset point 0 (tm-result-end end-result))
                   (return))
                  (t
                   (line-offset point 0 (tm-result-end best))
                   (tm-recompute-results results
                                         (line-string point)
                                         (point-charpos point))
                   (loop :for result :in results
                         :do (when (and result (eq (tm-result-syntax result) syntax))
                               (setf end-result result)
                               (return))))))))))
  
  (defun tm-apply-result (point result)
    (let ((syntax (tm-result-syntax result)))
  