dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

init.el (4032B)


      1 ;; -*- lexical-binding: t; -*-
      2 ;; Initial bootstrap
      3 ;; Start in fullscreen mode
      4 (message (concat "Starting: " (emacs-uptime)))
      5 
      6 ;; Garbage collection
      7 (setq gc-cons-percentage 1.0)
      8 (add-hook 'focus-out-hook #'garbage-collect)
      9 
     10 ;; prevent emacs trying to resize itself. maybe a startup time boost.
     11 ;; see here
     12 ;; https://tony-zorman.com/posts/2022-10-22-emacs-potpourri.html
     13 (setq frame-inhibit-implied-resize t)
     14 
     15 ;; Get rid of all bars
     16 ;; Note: this hinders discoverability! Not a problem for me, because
     17 ;; counsel-M-x gives discoverability with fuzzy-finding and
     18 ;; tmm-menubar still lets me use the menubar when needed. But this is
     19 ;; worth considering.
     20 (when (or window-system (daemonp))
     21   (menu-bar-mode -1)
     22   (tool-bar-mode -1)
     23   (scroll-bar-mode -1)
     24   (tooltip-mode -1))
     25 
     26 ;; If we have native compilation, disable showing them, they get
     27 ;; annoying (but still want to log them)
     28 (if (native-comp-available-p)
     29     (setq native-comp-async-report-warnings-errors 'silent))
     30 
     31 ;; Hide 'package CL is deprecated' warning
     32 (setq byte-compile-warnings '(cl-functions))
     33 
     34 ;; Set a consistent shell
     35 (setopt shell-file-name "/bin/sh")
     36 
     37 ;; Set up custom opener command
     38 (defun za/open (what)
     39   "Use ~/.scripts/open to open a file"
     40   (shell-command (concat "~/.scripts/open " what)))
     41 
     42 ;; If there's a problem verifying certs:
     43 ;; (when (string-equal system-type "darwin")
     44 ;;   (setq package-check-signature nil))
     45 
     46 ;; Also some problems connecting to package repos on Mac & a specific version
     47 ;; https://emacs.stackexchange.com/questions/68288/error-retrieving-https-elpa-gnu-org-packages-archive-contents
     48 (when (and (equal emacs-version "27.2")
     49            (eql system-type 'darwin))
     50   (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
     51 
     52 ;; Replace "yes/no" with "y"/"no"
     53 (when (fboundp 'y-or-n-p)
     54   (fset 'yes-or-no-p 'y-or-n-p))
     55 
     56 ;; Set up packages
     57 (require 'package)
     58 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
     59 (add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/") t)
     60 (customize-set-variable 'package-install-upgrade-built-in t "Upgrade built-in packages")
     61 (package-initialize)
     62 
     63 ;; Custom lisp files directory
     64 (defconst za/manually-installed-package-dir (concat user-emacs-directory "lisp/") "The directory for packages (.lisp) that I manually install.")
     65 (make-directory za/manually-installed-package-dir t)
     66 (add-to-list 'load-path za/manually-installed-package-dir)
     67 (let ((default-directory  za/manually-installed-package-dir))
     68   (normal-top-level-add-subdirs-to-load-path))
     69 
     70 ;; Install and load use-package
     71 (unless (package-installed-p 'use-package)
     72   (package-install 'use-package))
     73 (eval-when-compile (require 'use-package))
     74 
     75 ;; Profiling - enable, then run `use-package-report`
     76 ;; (setq use-package-compute-statistics t)
     77 
     78 ;; Always auto-install packages:
     79 (require 'use-package-ensure)
     80 (setq use-package-always-ensure nil)
     81 
     82 (defun za/ignore-builtin (pkg)
     83   "Ignore built-in package PKG."
     84   (assq-delete-all pkg package--builtins)
     85   (assq-delete-all pkg package--builtin-versions))
     86 ;; (za/ignore-builtin 'org)
     87 (use-package org)
     88 
     89 ;; Follow symlinks without prompting (the org file is a symlink)
     90 (setq vc-follow-symlinks t)
     91 
     92 ;; Some config should not be public, so it's in a separate file:
     93 (load-file (file-truename (concat user-emacs-directory "secret.el")))
     94 
     95 ;; Load all other customization from the org file, only compile if necessary
     96 (let* ((.org (file-truename (concat user-emacs-directory "config.org"))) ; the .org file will be in VC
     97        (.el (concat user-emacs-directory "config.el")) ; config.el is generated, so won't be in VC
     98        (.org-modification-time (file-attribute-modification-time (file-attributes .org)))
     99        (.el-modification-time (file-attribute-modification-time (file-attributes .el)))
    100        (config-unchanged-p (and (file-exists-p .el) (time-less-p .org-modification-time .el-modification-time))))
    101 
    102   (require 'org-macs)
    103   (unless config-unchanged-p
    104     (require 'ob-tangle)
    105     (org-babel-tangle-file .org .el "emacs-lisp"))
    106   (load-file .el))