 
 (defun danylo/highlight-region-low-level (window)
   "Low-level region highlight function."
-  (let* ((pt (window-point window))
-         (mark (mark))
-         (start (min pt mark))
-         (end   (max pt mark))
-         (rol (window-parameter window 'internal-region-overlay))
-         (new (funcall redisplay-highlight-region-function
-                       start end window rol)))
-    (unless (equal new rol)
-      (set-window-parameter window 'internal-region-overlay new))))
+  (when (and (window-live-p window) (mark))
+    (let* ((pt (window-point window))
+           (mark (mark))
+           (start (min pt mark))
+           (end   (max pt mark))
+           (rol (window-parameter window 'internal-region-overlay))
+           (new (funcall redisplay-highlight-region-function
+                         start end window rol)))
+      (unless (equal new rol)
+        (set-window-parameter window 'internal-region-overlay new)))))
 
 (defun danylo/highlight-region (orig-fun &rest args)
   "A throttled (jit lock-style) replacement for Emacs' built-in

  (setq web-mode-markup-indent-offset 2
        web-mode-css-indent-offset 2
        web-mode-code-indent-offset 2)
  (sp-local-pair 'web-mode "%" "%")
  :config
  (require 'web-mode))

              "Prevent \"Active processes exist\" query when quitting Emacs."
              (cl-letf (((symbol-function #'process-list) (lambda ())))
                ad-do-it))))

;;;; Scrolling behaviour

