- hide certain elements if in GUI emacs including scroll bar, tool bar
- disable package.el
- Set any emacs specific env vars
see: https://www.reddit.com/r/emacs/comments/x9nmo6/getting_the_following_error_warning_comp/
(setq package-enable-at-startup nil)
;; configure PATH env for gui
(setq exec-path (append exec-path '("/usr/local/bin")))
;;(setq exec-path (append exec-path '("/opt/homebrew/bin")))
;;(setq exec-path (append exec-path '("/opt/homebrew/lib")))
;; native compilation having issues finding gcc libraries on mac
;;(setq exec-path (append exec-path '("/opt/homebrew/lib/gcc/14")))
;;(setq exec-path (append exec-path '("/opt/homebrew/sbin")))
(setq exec-path (append exec-path '("/Users/hunterri/go/bin")))
(setq exec-path (append exec-path '("/Users/hunterri/.cargo/bin")))
(setq exec-path (append exec-path '("/Users/hunterri/.nvm/versions/node/v20.15.0/bin")))
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
;;(setenv "PATH" (concat (getenv "PATH") ":/opt/homebrew/bin"))
;;(setenv "PATH" (concat (getenv "PATH") ":/opt/homebrew/lib"))
;;(setenv "PATH" (concat (getenv "PATH") ":/opt/homebrew/lib/gcc/14"))
;;(setenv "PATH" (concat (getenv "PATH") ":/opt/homebrew/sbin"))
(setenv "PATH" (concat (getenv "PATH") ":/Users/hunterri/go/bin"))
(setenv "PATH" (concat (getenv "PATH") ":/Users/hunterri/.cargo/bin"))
(setenv "PATH" (concat (getenv "PATH") ":/Users/hunterri/.nvm/versions/node/v20.15.0/bin"))
(setenv "LIBRARY_PATH" (concat (getenv "LIBRARY_PATH") "/opt/homebrew/lib/gcc/14/gcc/aarch64-apple-darwin23/14"))
(setq inhibit-startup-message t
site-run-file nil ; No site-wide run-time initializations
inhibit-default-init t ; No site-wide default library
use-file-dialog nil
frame-resize-pixelwise t
frame-inhibit-implied-resize t
use-dialog-box t ; only for mouse events, which I seldom use
inhibit-startup-buffer-menu t
inhibit-splash-screen t)
(setq comp-async-report-warnings-errors nil)
;; The default is 800 kilobytes. Measured in bytes.
(setq gc-cons-threshold (* 50 1000 1000))
;; Profile emacs startup
(add-hook 'emacs-startup-hook
(lambda ()
(message "*** Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
;; I do not use those graphical elements by default, but I do enable
;; them from time-to-time for testing purposes or to demonstrate
;; something.
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(defun rh-emacs-re-enable-frame-theme (_frame)
"Re-enable active theme, if any, upon FRAME creation.
Add this to `after-make-frame-functions' so that new frames do
not retain the generic background set by the function
`rh-emacs-avoid-initial-flash-of-light'."
(when-let ((theme (car custom-enabled-themes)))
(enable-theme theme)))
;; NOTE 2023-02-05: The reason the following works is because (i) the
;; `mode-line-format' is specified again and (ii) the
;; `prot-emacs-theme-gsettings-dark-p' will load a dark theme.
(defun rh-emacs-avoid-initial-flash-of-light ()
"Avoid flash of light when starting Emacs, if needed.
New frames are instructed to call `prot-emacs-re-enable-frame-theme'."
(setq mode-line-format nil)
(set-face-attribute 'default nil :background "#000000" :foreground "#ffffff")
(set-face-attribute 'mode-line nil :background "#000000" :foreground "#ffffff" :box 'unspecified)
(add-hook 'after-make-frame-functions #'rh-emacs-re-enable-frame-theme))
(rh-emacs-avoid-initial-flash-of-light)
;; (add-hook 'after-init-hook (lambda () (set-frame-name "home")))
;; bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; set use-package to use straight.el
(setq straight-use-package-by-default t)