feat(emacs): Change vanilla emacs to straight.el

This commit is contained in:
js0ny 2025-03-14 16:06:52 +00:00
parent cfc5fc14af
commit 918f8a6ed5
5 changed files with 38 additions and 49 deletions

View file

@ -0,0 +1 @@
(setq package-enable-at-startup nil)

View file

@ -16,6 +16,18 @@
;; Store the auto-generated custom config to `custom.el`
(setq custom-file (expand-file-name ".custom.el" user-emacs-directory))
(defvar xdg-data-home
(or (getenv "XDG_DATA_HOME")
(expand-file-name "~/.local/share")))
(defvar xdg-cache-home
(or (getenv "XDG_CACHE_HOME")
(expand-file-name "~/.local/cache")))
(defvar user-emacs-data (expand-file-name "emacs" xdg-data-home))
(defvar user-emacs-cache (expand-file-name "emacs" xdg-cache-home))
;; Load each modules
(require 'init-package) ; package manager should be loaded first
(require 'init-basic)

View file

@ -14,16 +14,6 @@
:hook
(prog-mode . display-line-numbers-mode))
(defvar xdg-data-home
(or (getenv "XDG_DATA_HOME")
(expand-file-name "~/.local/share")))
(defvar xdg-cache-home
(or (getenv "XDG_CACHE_HOME")
(expand-file-name "~/.local/cache")))
(defvar user-emacs-data (expand-file-name "emacs" xdg-data-home))
(defvar user-emacs-cache (expand-file-name "emacs" xdg-cache-home))
;; https://book.emacs-china.org/#orgcfd105e Open with Emacs

View file

@ -6,7 +6,7 @@
;; Org General
(use-package org
:ensure nil ;; Use Emacs built-in Org Mode
:straight (:type built-in) ;; Tell straight to not install org
:config
(setq org-log-done 'time)
(setq org-startup-indented nil)
@ -161,11 +161,11 @@
;; Run source block with C-c C-c
;; Add supports for non-elisp langs
(use-package ob-python
:ensure nil ; Part of Org Mode
:straight (:type built-in) ; Part of Org Mode
:after org)
(use-package ob-C ;; C++ support is integrated in ob-C
:ensure nil ; Part of Org Mode
:straight (:type built-in) ; Part of Org Mode
:after org)
(org-babel-do-load-languages

View file

@ -1,45 +1,31 @@
;;; init-package.el
;;; init-package.el --- Package management setup using straight.el -*- lexical-binding: t -*-
;; Initialise the package sources
(require 'package)
; Add sources
;; (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("gnu" . "https://elpa.gnu.org/packages/")))
;; Initialise the package management system
(package-initialize)
(setq straight-base-dir (expand-file-name "straight" user-emacs-data))
;; Ensure the package list is up-to-date
(unless package-archive-contents
(package-refresh-contents))
;; Bootstrap 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))
;; Ensure use-package is installed
(unless (package-installed-p 'use-package)
; (package-refresh-contents) Move to above
(package-install 'use-package))
;; Use `use-package` for plugin management
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t)
;; use-package offers many syntax sugar.
;; :bind -> bindkeys
;; :config -> `(progn do sth)
;; :init -> (progn do sth)
;; :after -> (when (featurep 'package)do sth)
;; :hook -> (add-hook 'some-hook #'some-mode)
;; This part initialse the GPG Keyring
; Disable signature first
(setq package-check-signature nil)
;; Use straight.el with use-package
(straight-use-package 'use-package)
(setq straight-use-package-by-default t) ;; Automatically use straight for all packages
;; Ensure gnu-elpa-keyring-update (equivalent to your previous keyring update logic)
(use-package gnu-elpa-keyring-update)
; Re-enable signature
(setq package-check-signature 'allow-unsigned)
;; Which Key - Prompt available commands
(use-package which-key