         (point-line-nr (line-number-at-pos)))
     (unless (and (= live-py-window-start-pos window-start-pos)
                  (= live-py-point-line-nr point-line-nr))
-      (set (make-local-variable 'live-py-window-start-pos) window-start-pos)
-      (set (make-local-variable 'live-py-point-line-nr) point-line-nr)
+      (setq-local live-py-window-start-pos window-start-pos)
+      (setq-local live-py-point-line-nr point-line-nr)
       (if (buffer-live-p (and live-py-output-buffer
                               (get-buffer live-py-output-buffer)))
           (progn

                              (get-buffer live-py-output-buffer)))))
    (save-restriction
      (widen)
      ;; Create (or recreate) if necessary, update and last but not least
      ;; display output buffer.
      (if (eq 0
              (shell-command-on-region 1
                                       (1+ (buffer-size))
                                       command-line
                                       live-py-output-buffer))
          (setq live-py-lighter " live")
        (setq live-py-lighter " live(FAIL)")))
    (with-current-buffer live-py-output-buffer
      (setq buffer-read-only 1)
      (unless reused-buffer (toggle-truncate-lines 1)))
    (live-py-synchronize-scroll
     (line-number-at-pos (window-start)) (line-number-at-pos))
    (set 'live-py-timer nil)))

(defun live-py-synchronize-scroll (window-start-line-nr point-line-nr)
  "Synchronize scrolling between Python and output buffer.

;; If that doesn't work, put the following in your Emacs configuration file:
;;
;;   (require 'live-py-mode)

;;; Code:

;; User variables. The decision if local or not has to be left to the user.
(defvar live-py-driver nil)
(defvar live-py-dir nil)
(defvar live-py-path nil)
(defvar live-py-version nil)

;; Internal variables.
(defvar live-py-output-window nil)
(defvar-local live-py-timer nil)
(defvar-local live-py-output-buffer nil "The name of the output buffer.")
(defvar-local live-py-module nil)
(defvar-local live-py-parent nil)
(defvar-local live-py-window-start-pos nil)
(defvar-local live-py-point-line-nr nil)
(defvar-local live-py-lighter nil)

(defun live-py-after-change-function (start stop len)
  "After a delay run the buffer through the code tracer and show trace.
START, STOP and LEN are required by `after-change-functions' but unused."
  (ignore start stop len)
  (when live-py-timer (cancel-timer live-py-timer))
  (setq-local live-py-timer (run-at-time 0.5 nil 'live-py-trace)))

(defun live-py-trace ()
  "Trace the Python code using code_tracer.py."
