                                (symbol-name buffer-file-coding-system))))
 
   (spaceline-define-segment *major-mode
+    "The major mode, including process, environment and text-scale info."
     (concat
-     (and (featurep 'face-remap) (/= text-scale-mode-amount 0) (format "(%+d) " text-scale-mode-amount))
-     (if (stringp mode-name) mode-name (car mode-name))
-     (if (stringp mode-line-process) mode-line-process))
+     (format "%s" mode-name)
+     (if (stringp mode-line-process) mode-line-process)
+     (if narf--env-version (concat " " narf--env-version))
+     (and (featurep 'face-remap)
+          (/= text-scale-mode-amount 0)
+          (format " (%+d)" text-scale-mode-amount)))
     :tight-right t)
 
-  (defun narf--col-at-pos (pos)
-    (save-excursion (goto-char pos) (current-column)))
   (spaceline-define-segment *selection-info
-    "Information about the size of the current selection, when applicable.
-Supports both Emacs and Evil cursor conventions."
+    "Information about the current selection."
     (let ((reg-beg (region-beginning))
-          (reg-end (region-end)))
-      (let* ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
-             (chars (- (1+ reg-end) reg-beg))
-             (cols (1+ (abs (- (narf--col-at-pos reg-end)
-                               (narf--col-at-pos reg-beg)))))
-             (evil (eq 'visual evil-state))
-             (rect (or (bound-and-true-p rectangle-mark-mode)
-                       (and evil (eq 'block evil-visual-selection))))
-             (multi-line (or (> lines 1) (eq 'line evil-visual-selection))))
+          (reg-end (region-end))
+          (evil (eq 'visual evil-state)))
+      (let ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
+            (chars (- (1+ reg-end) reg-beg))
+            (cols (1+ (abs (- (evil-column reg-end)
+                              (evil-column reg-beg))))))
         (cond
-         (rect (format "%dx%dB" lines (if evil cols (1- cols))))
-         (multi-line
+         ;; rectangle selection
+         ((or (bound-and-true-p rectangle-mark-mode)
+              (and evil (eq 'block evil-visual-selection)))
+          (format "%dx%dB" lines (if evil cols (1- cols))))
+         ;; line selection
+         ((or (> lines 1) (eq 'line evil-visual-selection))
           (if (and (eq evil-state 'visual) (eq evil-this-type 'line))
               (format "%dL" lines)
             (format "%dC %dL" chars lines)))

  (defvar-local narf--env-version nil)
  (defvar-local narf--env-command nil)
  (defvar powerline-height 23)
  (setq-default
   powerline-default-separator nil
   spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)

  :config
  (defface mode-line-is-modified nil "Face for mode-line modified symbol")
  (defface mode-line-buffer-file nil "Face for mode-line buffer file path")

  ;; Custom modeline segments
  (spaceline-define-segment *buffer-size ""
    "%I"
    :when buffer-file-name
    :tight-right t)

  (spaceline-define-segment *buffer-path
    (if buffer-file-name
        (let* ((project-path (narf/project-root))
               (buffer-path (f-relative buffer-file-name project-path))
               (max-length 40))
          (concat (projectile-project-name) "/"
                  (if (> (length buffer-path) max-length)
                      (let ((path (reverse (split-string buffer-path "/")))
                            (output ""))
                        (when (and path (equal "" (car path)))
                          (setq path (cdr path)))
                        (while (and path (< (length output) (- max-length 4)))
                          (setq output (concat (car path) "/" output))
                          (setq path (cdr path)))
                        (when path
                          (setq output (concat "../" output)))
                        output)
                    buffer-path)))
      "%b")
    :face (if active 'mode-line-buffer-file 'mode-line-inactive)
    :skip-alternate t
    :tight-right t)

  (spaceline-define-segment *remote-host
    "Hostname for remote buffers."
    (concat "@" (file-remote-p default-directory 'host))
    :when (file-remote-p default-directory 'host))

  (spaceline-define-segment *buffer-modified
    (concat
     (when buffer-file-name
       (concat
        (when (buffer-modified-p) "[+]")
        (unless (file-exists-p buffer-file-name) "[!]")))
     (if buffer-read-only "[RO]"))
    :face mode-line-is-modified
    :when (not (string-prefix-p "*" (buffer-name)))
    :skip-alternate t
    :tight t)

              (y-or-n-p ">> Gee, I dunno Brain... Are you sure?")
            t))))

(tooltip-mode -1)  ; show tooltips in echo area
;; set up minibuffer and fringe
(if (not window-system)
    (menu-bar-mode -1)
