;;; 04-custom-init --- Provide custom basic init for emacs

;;; Commentary:

;;; Code:

(defvar backup-dir (expand-file-name "~/.emacs.d/backup/") "Set the default location of file backups.")
;; (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/") "Set the default location of autosaves.")

(cond ((member "PragmataPro Liga" (font-family-list))
       (set-face-attribute 'default nil :font "PragmataPro Liga-16")))

(setq-default initial-scratch-message nil
              backup-directory-alist (list (cons ".*" backup-dir))
              ;; auto-save-list-file-prefix autosave-dir
              ;; auto-save-file-name-transforms `((".*" ,autosave-dir t))
              )

;; Turn off the menus, scrollbars, and toolbars
(menu-bar-mode 0)
(scroll-bar-mode 0)
(tool-bar-mode 0)
(horizontal-scroll-bar-mode 0)
;; Revert to file on disk if it changes
(global-auto-revert-mode t)
;; Highlight the current line
(when window-system (global-hl-line-mode t))
;; Global line numbering
(global-linum-mode 0)
;; Show the column number after the line number (i.e. 50:57)
(column-number-mode t)
;; C-c <left>|<right> to undo|redo window changes like adding buffers.
(winner-mode t)
;; Show matching paren
(show-paren-mode t)
;; Pretty Symbols
(when window-system (global-prettify-symbols-mode t))

;; Meta-b better defaults testStringHereToTestBelow_Setting
(global-subword-mode 1)

;; Indent w/spaces only
(setq indent-tabs-mode nil
      tab-width 4)
(setq-default indent-tabs-mode nil
              tab-width 4)
;; This will expand 4 8 12 16 ... 200
(setq tab-stop-list (number-sequence 4 200 4))

;; Prevent stale elisp bytecode
(setq load-prefer-newer t)
;; Add newline on save
(setq require-final-newline t)

;; C-c to copy in Linux can be pasted in emacs
(setq select-enable-clipboard t)
;; after mouse selection can be pasted in emacs
(setq select-enable-primary t)
;; Paste at current point, not mouse location when "middle-clicking"
(setq mouse-yank-at-point t)

(add-hook 'prog-mode-hook (lambda() (add-hook 'before-save-hook #'delete-trailing-whitespace t t)))

;; Set auth source
;; (setq auth-sources '("~/.authinfo.gpg"))

;; Set window location/size
(if (eq system-type 'darwin)
    (progn
      (set-frame-position (selected-frame) 811 816)
      (set-frame-height (selected-frame) 55)
      (set-frame-width (selected-frame) 220))
  (message "Don't configure location for other OSes"))

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

(defalias 'yes-or-no-p 'y-or-n-p)

(defvar browse-url-generic-program)
(defvar engine/browser-function)
;; (setq ; browse-url-generic-program "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
;; browse-url-browser-function 'browse-url-generic)

(setq browse-url-browser-function 'browse-url-generic
      ;; engine/browser-function 'browse-url-generic
      ;; Chrome because Firefox will complain that a copy is already open.
      browse-url-generic-program "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe")

(defun display-startup-echo-area-message ()
  "Display startup echo area message."
  (message "Initialized in %s" (emacs-init-time)))

(provide '04-custom-init)
;;; 04-custom-init.el ends here
