;;; pre-settings.el --- Summary  -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; count startup time
(add-hook 'emacs-startup-hook                      ;; Use a hook so the message doesn't get clobbered by other messages.
          (lambda ()
            (message
             "Emacs ready in %s with %d garbage collections."
             (format "%.2f seconds" (float-time (time-subtract after-init-time before-init-time)))
             gcs-done)))

;; omit warnings like: /opt/emacs-conf/lisp/org/oc-basic.el: Warning: ‘buffer-substring’ is an obsolete generalized variable.
(setq byte-compile-warnings nil)

(require 'use-package)                             ;; requires bind-key
(setq use-package-verbose t)
(setq use-package-compute-statistics t)
(use-package delight)                              ;; used for use-package :delight, see delight-delighted-modes

;;
;; functions
;;
(defun my-font-installed-p (font-name)
  "Check if font with FONT-NAME is available."
  (when (find-font (font-spec :name "all-the-icons")) t))

;;
;; variables
;;
(defvar running-on-windows
  (memq system-type '(windows-nt cygwin32 cygwin))
  "Non-nil if and only if we're running on Windows.
Both Win32 and Cygwin count.")
;; https://stackoverflow.com/questions/60922620/shell-script-to-check-if-running-in-windows-when-using-wsl
(defvar running-on-windows-wsl
  (string-equal
   (replace-regexp-in-string
    "[ \n]+$" ""
    (shell-command-to-string
     "uname -a | sed -n 's/.*\\( *Microsoft *\\).*/\\1/ip'"))
   "Microsoft"))
(defvar my-dbusp
  (and (boundp 'dbus-compiled-version)  ;; t on WSL Debian machine
       (if (require 'dbus) (dbus-ping :session "org.freedesktop.Notifications")))  ;; is not enough
  "Check if DBus is available.")

(use-package cus-edit
  :config
  (setq custom-file (concat user-emacs-directory "custom.el"))
  (setq custom-buffer-done-kill t)
  (load custom-file t t))

(provide 'pre-settings)
;;; pre-settings.el ends here
