 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+(use-package popwin
+  :config
+  (mapc (lambda (rule) (push rule popwin:special-display-config))
+        '(("*quickrun*" :position bottom :height 15)
+          ("*scratch*" :position bottom :height 20 :stick t :dedicated t)
+          ("*helm-ag-edit*" :position bottom :height 20 :stick t)
+          ("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 15)
+          ("*eshell*" :position left :width 80 :stick t :dedicated t)))
+  (popwin-mode 1))
+
 (use-package yascroll
   :config
+  (add-hook! evil-insert-state-exit 'yascroll:update-scroll-bar)
+
+  (defun yascroll:show-scroll-bar ()
+    "Show scroll bar in BUFFER."
+    (interactive)
+    (yascroll:hide-scroll-bar)
+    (let ((window-lines (window-height))
+          (buffer-lines (count-lines (point-min) (point-max))))
+      (when (< window-lines buffer-lines)
+        (let* ((scroll-top (count-lines (point-min) (window-start)))
+               (thumb-window-line (yascroll:compute-thumb-window-line window-lines buffer-lines scroll-top))
+               (thumb-buffer-line (+ scroll-top thumb-window-line))
+               (thumb-size (yascroll:compute-thumb-size window-lines buffer-lines))
+               (make-thumb-overlay 'yascroll:make-thumb-overlay-right-fringe))
+          (when (<= thumb-buffer-line buffer-lines)
+            (yascroll:make-thumb-overlays make-thumb-overlay
+                                          thumb-window-line
+                                          thumb-size))))))
+
   (defun yascroll:compute-thumb-size (window-lines buffer-lines)
     "Return the proper size (height) of scroll bar thumb."
-    (let ((window-lines (* window-lines 0.91)))
+    (let ((window-lines (* window-lines 0.93)))
       (if (zerop buffer-lines)
           1
-        (max 1 (floor (min (* (/ (float window-lines) buffer-lines) window-lines) buffer-lines))))))
+        (max 1 (floor (* (/ window-lines buffer-lines) window-lines))))))
 
   (setq yascroll:scroll-bar 'right-fringe
         yascroll:delay-to-hide nil)
   (add-to-list 'yascroll:enabled-window-systems 'mac)
-  (defadvice yascroll:before-change (around always-show-bar activate) ())
+  (defun yascroll:before-change (beg end))
   (global-yascroll-bar-mode 1))
 
 (use-package fill-column-indicator
-  :config
-  (setq fci-rule-color "#2b303f")
+  :commands fci-mode
+  :init
   (setq-default fill-column 80)
-  (add-hook! text-mode 'fci-mode))
+  (add-hook! (markdown-mode org-mode) 'fci-mode)
+  :config
+  (setq fci-rule-color "#2b303f"))
 
 (use-package nlinum ; line numbers
   :preface

      (minor-modes :separator " ")
      process :when active)
     (global :when active)
     narf-buffer-position
     narf-hud
     )))

(provide 'core-ui)

;; see lib/ui-defuns.el

(when window-system
  (fringe-mode '(3 . 2))
  (set-frame-font narf-default-font)
  (setq frame-title-format '(buffer-file-name "%f" ("%b"))))

