dotfiles

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

init.el (4073B)


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