-;;;; Emacs Configuration
+;;;; GNU Emacs Configuration
 ;;;; `~/.emacs.d/init.el'
 
-;; Add custom elisp files to `load-path'
-(add-to-list 'load-path "~/.emacs.d/elisp/")
-(let ((default-directory  "~/.emacs.d/elisp/"))
+
+;; Add custom elisp files to `load-path'.
+(let ((default-directory (concat user-emacs-directory "elisp")))
+  (add-to-list 'load-path default-directory)
   (normal-top-level-add-subdirs-to-load-path))
 
-;; UI config
+
+;;; Essentials
+
+(setq user-mail-address "av@axvr.io"
+      user-full-name "Alex Vear")
+
+;; Use UTF-8 character encoding.
+(set-language-environment "UTF-8")
+(set-default-coding-systems 'utf-8-unix)
+
+;; Update buffers and directory listing when files change on disk.
+(global-auto-revert-mode t)
+(add-hook 'dired-mode-hook 'auto-revert-mode)
+
+;; File backups and remember last cursor position.
+(setq backup-directory-alist `(("." . ,(concat user-emacs-directory "backup")))
+      backup-by-copying t
+      delete-old-versions t
+      version-control t
+      save-place-file (concat user-emacs-directory "places"))
+(save-place-mode 1)
+
+
+;;; UI config
+
 (menu-bar-mode -1)
 (if (display-graphic-p)
     (progn (tool-bar-mode -1)

(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http://" "https://")))
  (add-to-list 'package-archives (cons "melpa" (concat proto "melpa.org/packages/")) t)
  (add-to-list 'package-archives (cons "melpa-stable" (concat proto "stable.melpa.org/packages/")) t))

(setq package-archive-priorities
      '(("gnu" . 10)
        ("melpa" . 5)
        ("melpa-stable" . 0)))

(setq package-enable-at-startup nil)
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))


(use-package undo-propose
  :ensure t
  :config (global-set-key (kbd "C-c u") 'undo-propose))

(setq scheme-program-name "csi -:c")

(use-package clojure-mode :ensure t :defer t)

(use-package markdown-mode :ensure t :defer t)

(use-package org
  :ensure t
  :defer t
  :hook (org-mode . org-indent-mode)
  :config
  ;; TODO set org directory for org-agenda
  (require 'org-man))

(use-package restclient :ensure t :mode ("\\.restclient\\'" . restclient-mode))

(use-package ledger-mode :ensure t :defer t)
;; FIXME `ledger-mode-clean-buffer' should sort in reverse order

(custom-set-variables
 ;; custom-set-variables was added by Custom.


(show-paren-mode 1)
(column-number-mode 1)
(electric-pair-mode 1)
;; (add-hook 'prog-mode-hook 'hl-line-mode)
;; (add-hook 'prog-mode-hook 'prettify-symbols-mode)

;; (define-minor-mode av/hl-todos-mode
;;   "Highlight TODOs and other common comment keywords"
;;   nil
;;   :lighter ""
;;   (font-lock-add-keywords
;;    nil '(("\\<\\(TO[-_ ]?DO\\|FIX[-_ ]?ME\\|NOTE\\|XXX\\|BUG\\|HACK\\|UNDONE\\)\\>"
;;           1 '((:foreground "#d75f5f") (:weight bold)) t))))
;; (add-hook 'prog-mode-hook 'av/hl-todos-mode)

(setq scheme-program-name "csi -:c")


;;; Packages
