/ gc.el
gc.el
1 ;;; gc.el --- Backpack garbage collection mode -*- lexical-binding: t; -*- 2 ;; 3 ;; This file implements the `backpack gc' command which: 4 ;; 1. Scans current configuration to determine which packages are needed 5 ;; 2. Compares against installed packages 6 ;; 3. Removes orphaned packages that are no longer required 7 ;; 8 ;; Usage: emacs --batch --eval "(setq user-emacs-directory \"/path/to/emacs-backpack/\")" -l gc.el 9 ;; For dry-run: emacs --batch --eval "(setq user-emacs-directory \"/path/to/emacs-backpack/\")" -l gc.el --eval "(setq backpack-gc-dry-run t)" 10 11 ;; Check for dry-run flag (can be set via command line) 12 (defvar backpack-gc-dry-run nil 13 "When non-nil, perform a dry run without deleting anything.") 14 15 ;; Set up load paths for base-packages before loading backpack.el 16 (add-to-list 'load-path (expand-file-name "base-packages/leaf.el" user-emacs-directory)) 17 (add-to-list 'load-path (expand-file-name "base-packages/leaf-keywords.el" user-emacs-directory)) 18 (add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) 19 20 ;; Load backpack.el which sets up all the infrastructure 21 (let ((backpack-file (expand-file-name "lisp/backpack.el" user-emacs-directory))) 22 (load backpack-file nil nil nil t)) 23 24 ;; Run garbage collection 25 (message "") 26 (message "========================================") 27 (message "Backpack Garbage Collection") 28 (message "========================================") 29 (message "") 30 31 (backpack-gc backpack-gc-dry-run) 32 33 (message "") 34 (kill-emacs 0)