Files
memex/system/emacs-core.org

4.2 KiB

Core Emacs Configuration

Initialization Bootstrap

This section tangles directly to ~/.emacs to bootstrap the entire system.

  ;;; .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)

Front matter

  ;;; emacs-core.el --- Summary
  ;;; Commentary:
  ;;; Code:

  ;; -*- lexical-binding: t; -*-

Garbage collector

Increase threshold to 500 MB to ease startup

  (setq gc-cons-threshold (* 500 1024 1024))

Decrease threshold to 5 MB after init

  (add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024))))

Straight.el and use-package

Integrate use-package and straight

  (setq straight-use-package-by-default t)
  (require 'use-package)
  (straight-use-package 'diminish)
  (require 'diminish)

Make sure Org is installed (straight.el)

  (unless (file-directory-p (expand-file-name "~/.emacs.d/straight/versions")) (make-directory (expand-file-name "~/.emacs.d/straight/versions") t))
  (use-package org)

Custom file

  (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
  (when (file-exists-p custom-file) (load custom-file))

System information

  (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

Persistent history

  (savehist-mode)

Disable Syntax Checkers (Diagnostic)

  (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))))

Backup and versioning

  (use-package magit)

Personal information

  (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")

Saving Emacs Sessions

Close frame when done

  (add-hook 'server-done-hook (lambda () (delete-frame)))

Save desktop session

  (desktop-save-mode t)

Security

  (use-package password-store)
  (use-package auth-source
    :config (auth-source-pass-enable)
    )

End matter

  (provide 'emacs-core)
  ;;; emacs-core.el ends here