Files
memex/projects/dotemacs/docs/emacs-core.org

4.1 KiB

Core Emacs Configuration

Front matter

  ;;; .emacs --- Global settings
  ;;; Commentary:
  ;;; Code:

  ;; -*- lexical-binding: t; -*-
  ;;; config.el --- Summary
  ;;; Commentary:
  ;;; Code:

  ;; -*- lexical-binding: t; -*-
  ;;; custom.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

Bootstrap Straight.el and install use-package

  (setq straight-repository-branch "develop") ;; Using develop branch temporarily to fix the org-roam-dailies issue.

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

Integrate use-package and straight

  (setq straight-use-package-by-default t)

Make sure Org is installed (straight.el)

  (unless (file-directory-p "~/.emacs.d/straight/versions") (make-directory (concat user-emacs-directory "straight/versions")))
  (use-package org)

A use-package declaration for simplifying your .emacs

  (require 'use-package)

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)

Backup and versioning

  (use-package magit
    :ensure t
    )

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)
  ;;; .emacs ends here
  (provide 'config)
  ;;; config.el ends here
  (provide 'custom)
  ;;; custom.el ends here