 
 When the source buffer is narrowed the trace buffer remains
 aligned but will not hide the part after the narrowing."
-  (let ((output-window (get-buffer-window live-py-trace-name))
-        (point-min-pos (point-min))
-        (point-min-line-nr 1))
-    (unless (= 1 point-min-pos)
-      ;; Compensate for narrowing.
-      (save-restriction
-        (widen)
-        (setq point-min-line-nr (line-number-at-pos point-min-pos))))
+  (let* ((output-window (get-buffer-window live-py-trace-name))
+         (point-min-pos (point-min))
+         (point-min-line-nr (if (= 1 point-min-pos)
+                                1
+                              ;; Compensate for narrowing.
+                              (save-restriction
+                                (widen)
+                                (line-number-at-pos point-min-pos)))))
     (unless output-window
       (live-py-create-output-window))
     (with-selected-window output-window

          live-py-version "python")

    ;; Internal variables.
    (setq-local live-py-source-last-active-window (get-buffer-window))
    ;; Create a unique name for the trace buffer.
    (setq-local live-py-trace-name

  :group 'live-py-mode
  :lighter live-py-lighter
  :keymap (let ((map (make-sparse-keymap)))
            (define-key map (kbd "C-c M-d") #'live-py-set-driver)
            (define-key map (kbd "C-c M-w") #'live-py-set-dir)
            (define-key map (kbd "C-c M-p") #'live-py-set-path)
            (define-key map (kbd "C-c M-v") #'live-py-set-version)
            map)
  (unless (buffer-file-name)
    (user-error "Current buffer has no associated file"))
  (cond
