#+TITLE: Core Emacs Configuration #+PROPERTY: header-args :tangle yes * Initialization Bootstrap This section tangles directly to ~/.emacs to bootstrap the entire system. #+begin_src elisp :tangle ~/.emacs ;;; .emacs --- Global settings -*- lexical-binding: t; -*- (setq gc-cons-threshold (* 500 1024 1024)) (add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024)))) (setq straight-repository-branch "develop") (eval-and-compile (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" (or (bound-and-true-p straight-base-dir) user-emacs-directory))) (bootstrap-version 7)) (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)) (straight-use-package 'use-package) (straight-use-package 'org)) (setq straight-use-package-by-default t) (require 'ob-tangle) ;; Load the modular configuration starting from dotemacs.org (org-babel-load-file (expand-file-name "~/memex/system/dotemacs.org")) (provide '.emacs) #+end_src * Front matter #+begin_src elisp ;;; emacs-core.el --- Summary ;;; Commentary: ;;; Code: ;; -*- lexical-binding: t; -*- #+end_src * Garbage collector Increase threshold to 500 MB to ease startup #+begin_src elisp (setq gc-cons-threshold (* 500 1024 1024)) #+end_src Decrease threshold to 5 MB after init #+begin_src elisp (add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024)))) #+end_src * Straight.el and use-package Integrate use-package and straight #+begin_src elisp (setq straight-use-package-by-default t) (require 'use-package) (straight-use-package 'diminish) (require 'diminish) #+end_src Make sure Org is installed (straight.el) #+begin_src elisp (unless (file-directory-p (expand-file-name "~/.emacs.d/straight/versions")) (make-directory (expand-file-name "~/.emacs.d/straight/versions") t)) (use-package org) #+end_src * Custom file #+begin_src elisp (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (when (file-exists-p custom-file) (load custom-file)) #+end_src * System information #+begin_src elisp (defvar my-laptop-p (equal (system-name) "lilitop")) (defvar my-server-p (and (equal (system-name) "localhost") (equal user-login-name "root"))) (defvar my-phone-p (not (null (getenv "ANDROID_ROOT"))) "If non-nil, GNU Emacs is running on Termux.") (when my-phone-p (defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")) (global-auto-revert-mode) ; simplifies syncing #+end_src * Persistent history #+begin_src elisp (savehist-mode) #+end_src * Disable Syntax Checkers (Diagnostic) #+begin_src elisp (when (fboundp 'flycheck-mode) (setq flycheck-global-modes nil) (global-flycheck-mode -1)) (when (fboundp 'flymake-mode) (setq help-at-pt-display-when-idle t) ;; Disable flymake in all buffers (add-hook 'find-file-hook (lambda () (flymake-mode -1)))) #+end_src * Backup and versioning #+begin_src emacs-lisp (use-package magit) #+end_src * Personal information #+begin_src elisp (setq user-full-name "Amr Gharbeia") (defvar email-address "amr@gharbeia.net") (defvar calendar-latitude 39.0) (defvar calendar-longitude -77.1) (defvar calendar-location-name "Washington, DC") (defvar calendar-time-zone -300) (defvar calendar-standard-time-zone-name "EST") (defvar calendar-daylight-time-zone-name "EDT") #+end_src * Saving Emacs Sessions Close frame when done #+begin_src elisp (add-hook 'server-done-hook (lambda () (delete-frame))) #+end_src Save desktop session #+begin_src elisp (desktop-save-mode t) #+end_src * Security #+begin_src elisp (use-package password-store) #+end_src #+begin_src elisp (use-package auth-source :config (auth-source-pass-enable) ) #+end_src * End matter #+begin_src elisp (provide 'emacs-core) ;;; emacs-core.el ends here #+end_src