nixos/config/emacs/emacs.org

1 line
39 KiB
Org Mode
Raw Normal View History

2024-07-19 02:15:01 +04:00
#+title: EMACS 2 #+PROPERTY: header-args:emacs-lisp :tangle yes :tangle init.el * Welcome! #+begin_src emacs-lisp ;; -*- lexical-binding: t; -*- #+end_src * Package Setup #+begin_src emacs-lisp (message "Reached package setup") (require `package) (setq package-archives `(("mepla" . "https://melpa.org/packages/") ("org" . "https://orgmode.org/elpa/") ("elpa" . "https://elpa.gnu.org/packages/"))) (package-initialize) (unless (package-installed-p 'use-package) (progn (package-refresh-contents) (package-install 'use-package))) (require 'use-package) (setq use-package-always-ensure t) ;; TODO add better detection to this (when (eq system-type 'windows-nt) (message "setting up straight.el") (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)) (setq straight-use-package-by-default t)) #+end_src * Keybinds Ill use this later eventually #+begin_src emacs-lisp (message "Got to keybinds") #+end_src ** Make emacs more human #+begin_src emacs-lisp (global-set-key (kbd "<escape>") 'keyboard-escape-quit) #+end_src * Core #+begin_src elisp (message "Reached core.") #+end_src ** Encoding #+begin_src emacs-lisp (setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters) (set-language-environment 'utf-8) (set-keyboard-coding-system 'utf-8) ; For old Carbon emacs on OS X only (setq locale-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) (set-selection-coding-system (if (eq system-type 'windows-nt) 'utf-16-le ;; https://rufflewind.com/2014-07-20/pasting-unicode-in-emacs-on-windows 'utf-8)) (prefer-coding-system 'utf-8) #+end_src ** Cleanup .emacs.d #+begin_src emacs-lisp (setq backup-directory-alist '(("." . "~/.emacs.d/backup")) backup-by-copying t version-control t delete-old-versions t kept-new-versions 20 kept-old-versions 5) (use-package no-littering :config (setq custom-file (if (boundp 'server-socket-dir) (expand-file-name "custom.el" server-socket-dir) (no-littering-expand-etc-file-name "custom.el"))) (when (file-exists-p custom-file) (load custom-file t)) ;; Don't litter project folders with backup files (let ((backup-dir (no-littering-expand-var-file-name "backup/"))) (make-directory backup-dir t) (setq backup-directory-alist `(("\\`/tmp/" . nil) ("\\`/dev/shm/" . nil) ("." . ,backup-dir)))) (setq auto-save-default nil) ;; Tidy up auto-save files (setq auto-save-default nil) (let ((auto-save-dir (no-littering-expand-var-file-name "auto-save/"))) (make-directory auto-save-dir t) (setq auto-save-file-name-transforms `(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" ,(concat temporary-file-directory "\\2") t) ("\\`\\(/tmp\\|/dev/shm\\)\\([^/]*/\\)*\\(.*\\)\\'" "\\3") ("." ,auto-save-dir t))))) ;; no-littering doesn't set this by default so we must place ;; auto save files in the same path as it uses for sessions (setq auto-save-file-name-transforms `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) #+end_src ** Native Compilation #+begin_src emacs-lisp (setq native-comp-async-report-warnings-errors nil) (add-to-list 'native-comp-eln-load-path (expand-file-name "eln-cache/" user-emacs-directory)) #+end_src ** Emacs settings #+begin_src emacs-lisp (setq inhibit-startup-message t