anchor.diff:  (defpackage :lem.go-back
     (:use :cl :lem :lem.sourcelist)
  -  (:export :select-go-back
  -           :go-back
  -           :go-forward))
  +  (:export :*max*
  +           :select-go-back
  +           :go-back-global
  +           :go-back))
   (in-package :lem.go-back)
   
  -(defvar *record-locations* '())
  -(defvar *len* 0)
  -(defvar *max* 100)
  +(defparameter *max* 100)
   
  -(defun elt-name (elt) (first elt))
  -(defun elt-linum (elt) (second elt))
  -(defun elt-charpos (elt) (third elt))
  +(defstruct record
  +  locations
  +  (len 0))
   
  -(defun point-to-elt (point)
  +(defvar *global-record* (make-record))
  +
  +(defun location-name (location) (first location))
  +(defun location-linum (location) (second location))
  +(defun location-charpos (location) (third location))
  +
  +(defun point-to-location (point)
     (list (buffer-name (point-buffer point))
           (line-number-at-point point)
           (point-charpos point)))
   
  -(defun equal-location (elt1 elt2)
  -  (and (equal (elt-name elt1)
  -              (elt-name elt2))
  -       (= (elt-linum elt1)
  -          (elt-linum elt2))))
  +(defun equal-location (location1 location2)
  +  (and (equal (location-name location1)
  +              (location-name location2))
  +       (= (location-linum location1)
  +          (location-linum location2))))
   
  -(defun record-location (point &optional tail)
  -  (let ((new-elt (point-to-elt point)))
  -    (when (if tail
  -              (equal-location new-elt
  -                              (car (last *record-locations*)))
  -              (equal-location new-elt
  -                              (car *record-locations*)))
  -      (return-from record-location))
  -    (if (<= *max* *len*)
  -        (progn
  -          (setf *record-locations* (nbutlast *record-locations* (1+ (- *len* *max*))))
  -          (setf *len* *max*))
  -        (incf *len*))
  -    (if tail
  -        (alexandria:nconcf *record-locations* (list new-elt))
  -        (push new-elt *record-locations*))))
  +(defun append-location (record location &optional tail)
  +  (when (if tail
  +            (equal-location location
  +                            (car (last (record-locations record))))
  +            (equal-location location
  +                            (car (record-locations record))))
  +    (return-from append-location))
  +  (if (<= *max* (record-len record))
  +      (progn
  +        (setf (record-locations record)
  +              (nbutlast (record-locations record)
  +                        (1+ (- (record-len record) *max*))))
  +        (setf (record-len record) *max*))
  +      (incf (record-len record)))
  +  (if tail
  +      (alexandria:nconcf (record-locations record)
  +                         (list location))
  +      (push location (record-locations record))))
   
   (define-command select-go-back () ()
     (with-sourcelist (sourcelist "*select-locations*" :focus t)
  -    (loop :for (name linum charpos) :in *record-locations*
  +    (loop :for (name linum charpos) :in (record-locations *global-record*)
             :for buffer := (get-buffer name)
             :when buffer
             :do (let ((name name)
  
positive.code:                     (line-offset p 0 charpos))
                    (return))))))
  
  (add-hook *set-location-hook* 'record-location)
  
negative.code:                      (line-offset (buffer-point buffer) 0 charpos)
                       (funcall set-buffer-fn buffer))))))))
  
  (defun go-back-internal (record n)
    (when (plusp n)
      (loop :while (record-locations record)
            :for location := (progn
                               (decf (record-len record))
                               (pop (record-locations record)))
            :for (buffer-name line-number charpos) := location
            :do (alexandria:when-let ((buffer (get-buffer buffer-name)))
                  (record-location (current-point) t)
                  (incf (record-len record))
                  (alexandria:nconcf (record-locations record) (list location))
                  (when (zerop (decf n))
                    (switch-to-buffer buffer)
                    (let ((p (buffer-point buffer)))
  