 
 (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


;;; ..:: Markdown ::..

(use-package markdown-mode
  ;; https://github.com/jrblevin/markdown-mode
  ;; Markdown editing major mode
  :mode (("README\\.md\\'" . gfm-mode)
         ("\\.md\\'" . markdown-mode)
         ("\\.markdown\\'" . markdown-mode))
  :init (setq markdown-command "multimarkdown")
  (add-hook 'markdown-mode-hook
            (lambda ()
              (filladapt-mode -1)
              (setq-local markdown-enable-math t)))
  (sp-local-pair 'markdown-mode "%" "%")
  (sp-local-pair 'markdown-mode "$" "$" :insert "C-c f e")
  (sp-local-pair 'markdown-mode "$$" "$$" :insert "C-c f d e"))

;;; ..:: Bash ::..


;; https://emacs.stackexchange.com/questions/28736/emacs-pointcursor-movement-lag
(setq auto-window-vscroll nil)

(electric-pair-mode 1)

;;;; Better electric indentation

(defvar-local danylo/do-electric-indent t)
