       turn-on-adaptive-wrap-prefix-mode)
     (global-adaptive-wrap-prefix-mode 1)))
 
-;; CURSOR
+;;; Cursor
 ;; Change cursor color according to mode:
 ;;   read-only buffer / overwrite / regular (insert) mode
 (blink-cursor-mode -1) ; Don't blink the cursor, it's distracting!

;; to work even in split windows
(setq-default truncate-partial-width-windows nil)

;; Visual Line Mode
;; Do word wrapping only at word boundaries
(defconst modi/visual-line-mode-hooks '(org-mode-hook
                                        markdown-mode-hook)

                                   (dired-directory dired-directory "%b")))))
(add-hook 'after-init-hook #'modi/update-frame-title)

;;; Fonts

;;;; Font Lock
;; Enable font-lock or syntax highlighting globally
(global-font-lock-mode 1)
;; Use the maximum decoration level available for color highlighting
(setq font-lock-maximum-decoration t)

;;;;; Syntax highlight .vimrc files (I know, blasphemy!)
;; http://stackoverflow.com/a/4238738/1219634
(define-generic-mode 'vimrc-generic-mode
  '()
  '()
  '(("^[\t ]*:?\\(!\\|ab\\|map\\|unmap\\)[^\r\n\"]*\"[^\r\n\"]*\\(\"[^\r\n\"]*\"[^\r\n\"]*\\)*$"
     (0 font-lock-warning-face))
    ("\\(^\\|[\t ]\\)\\(\".*\\)$"
     (2 font-lock-comment-face))
    ("\"\\([^\n\r\"\\]\\|\\.\\)*\""
     (0 font-lock-string-face)))
  '("/vimrc\\'" "\\.vim\\(rc\\)?\\'")
  '((lambda ()
      (modify-syntax-entry ?\" ".")))
  "Generic mode for Vim configuration files.")

(setq auto-mode-alist (append '(("\\.vimrc.*\\'" . vimrc-generic-mode)
                                ("\\.vim\\'"     . vimrc-generic-mode))
                              auto-mode-alist))

;;;; Fix italics
;; Make the italics show as actual italics. For some unknown reason, the below
;; is needed to render the italics in org-mode. The issue could be related to
;; the fonts in use. But having this doesn't hurt regardless.
(set-face-attribute 'italic nil :inherit nil :slant 'italic)

;;;; Windows Font
(when (eq system-type 'windows-nt)
  (set-face-attribute 'default nil :family "Consolas"))

;;;; Global Font Resize
(defun modi/global-font-size-adj (scale &optional absolute)
  "Adjust the font sizes globally: in all the buffers, mode line, echo area, etc.

The inbuilt `text-scale-adjust' function (bound to C-x C-0/-/= by default)
does an excellent job of font resizing. But it does not change the font sizes
of text outside the current buffer; for example, in the mode line.

M-<SCALE> COMMAND increases font size by SCALE points if SCALE is +ve,
                  decreases font size by SCALE points if SCALE is -ve
                  resets    font size if SCALE is 0.

If ABSOLUTE is non-nil, text scale is applied relative to the default font size
`default-font-size-pt'. Else, the text scale is applied relative to the current
font size."
  (interactive "p")
  (if (= scale 0)
      (setq font-size-pt default-font-size-pt)
    (if (bound-and-true-p absolute)
        (setq font-size-pt (+ default-font-size-pt scale))
      (setq font-size-pt (+ font-size-pt scale))))
  ;; The internal font size value is 10x the font size in points unit.
  ;; So a 10pt font size is equal to 100 in internal font size value.
  (set-face-attribute 'default nil :height (* font-size-pt 10)))

(defun modi/global-font-size-incr ()  (interactive) (modi/global-font-size-adj +1))
(defun modi/global-font-size-decr ()  (interactive) (modi/global-font-size-adj -1))
(defun modi/global-font-size-reset () (interactive) (modi/global-font-size-adj 0))

;; Initialize font-size-pt var to the default value
(modi/global-font-size-reset)

;; Usage: C-c - = - 0 = = = = - - 0
;; Usage: C-c = = 0 - = - = = = = - - 0
(defhydra hydra-font-resize (nil
                             "C-c"
                             :bind (lambda (key cmd) (bind-key key cmd modi-mode-map))
                             :color red
                             :hint nil)
  "
[Font Size]     _C--_/_-_ Decrease     _C-=_/_=_ Increase     _C-0_/_0_ Reset     _q_ Cancel
"
  ("C--" modi/global-font-size-decr)
  ("-"   modi/global-font-size-decr :bind nil)
  ("C-=" modi/global-font-size-incr)
  ("="   modi/global-font-size-incr :bind nil)
  ("+"   modi/global-font-size-incr :bind nil)
  ("C-0" modi/global-font-size-reset :color blue)
  ("0"   modi/global-font-size-reset :bind nil)
  ("q"   nil :color blue))

(global-unset-key (kbd "<C-down-mouse-1>"))
;; <C-down-mouse-1> is bound to `mouse-buffer-menu' by default. It is
;; inconvenient when that mouse menu pops up when I don't need it
;; to. And actually I have never used that menu :P

(bind-keys
 :map modi-mode-map
  ;; Make Control+mousewheel do increase/decrease font-size
  ;; http://ergoemacs.org/emacs/emacs_mouse_wheel_config.html
  ("<C-mouse-1>" . modi/global-font-size-reset) ; C + left mouse click
  ("<C-mouse-4>" . modi/global-font-size-incr) ; C + wheel-up
  ("<C-mouse-5>" . modi/global-font-size-decr)) ; C + wheel-down

(>=e "25.0"
    ;; Do not resize the frame when adjusting the font size
    (add-to-list 'frame-inhibit-implied-resize 'font))

;;; Line truncation
;; Enable truncation. This setting does NOT apply to windows split using `C-x 3`
(setq-default truncate-lines t)
;; Do `M-x toggle-truncate-lines` to toggle truncation mode.
