;; -*- lexical-binding: t; -*-
;; TURN ON IN INIT FILE!!!!!

;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; helper functions
;; Figure out if inside Termux
(require 'subr-x)
(setq kmn/is-termux
      (string-suffix-p "Android" (string-trim (shell-command-to-string "uname -a"))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; os specific config
(when (eq system-type 'windows-nt)
    ; Fix resolution of ~ to match other client paths
    (setenv "HOME" "C:/Users/mcros/Nextcloud")
    (setq default-directory "C:/Users/mcros/Nextcloud")

    ; add executables to path ahead of them being used by extensions / emacs stuff
    (add-to-list 'exec-path "C:/Users/mcros/OneDrive/Programs/PortableApps/sqlite3")
)
(when kmn/is-termux
    ; setup storage locations -- cheat so mobile/desktop look alike for file urls
    ;(setq user-init-file "/data/data/com.termux/files/home/storage/shared/.emacs")
    ;(setq user-emacs-directory "/data/data/com.termux/files/home/storage/shared/.emacs.d/")
    ;(setenv "HOME" "/data/data/com.termux/files/home/storage/shared/")
    ;(load user-init-file)

    ; Fix resolution of ~ to match other client paths
    (setenv "HOME" "/data/data/com.termux/files/home/storage/shared/")
    (setq default-directory "/data/data/com.termux/files/home/storage/shared/")

    ; Better fonts
    (setq org-src-fontify-natively t)

    ; Setup xdg-open as the default for opening files (except for the few we want emacs to open native)
    ; xdg-open is linked to termux-open by default ; if you need 'more' look into tmux-open and adjust accordingly
    ; (add-to-list 'org-file-apps '("\\.doc.*" . "open %s"))
    (setq org-file-apps
        '(;; default
            (auto-mode . emacs)
            ("\\.org" . emacs)
            ("\\.txt" . emacs)
            (".*" . "xdg-open %s")))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; global config
(load "~/.emacs.d.profiles/common/_global.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
