From 45bb0d11161b1c5077a1415eed6dbd0fd25ccb6a Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Fri, 20 Sep 2024 14:16:56 +0200 Subject: Change dotfiles structure, and add guix-channels declaration. --- files/.emacs.d/init.el | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100755 files/.emacs.d/init.el (limited to 'files/.emacs.d/init.el') diff --git a/files/.emacs.d/init.el b/files/.emacs.d/init.el new file mode 100755 index 0000000..090592f --- /dev/null +++ b/files/.emacs.d/init.el @@ -0,0 +1,146 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +;; Minimize garbage collection during startup +(setq gc-cons-threshold most-positive-fixnum) + +;; Lower threshold back to 8 MiB (default is 800kB) +(add-hook 'emacs-startup-hook + (lambda () + (setq gc-cons-threshold (expt 2 23)))) + +(defvar jd/manifest-list + nil + "List that contain Emacs packages for GNU/Guix." ) + +(defvar jd/exwm-p + (or (not (null (getenv "JD_EXWM"))) + (and (seq-contains command-line-args "exwm" #'string-match) + t)) + "Is non-nil when Emacs is run as a window manager.") + +(defvar jd/guix-p + (and (eq system-type 'gnu/linux) + (file-exists-p "/etc/os-release") + (with-temp-buffer + (insert-file-contents "/etc/os-release") + (search-forward "ID=guix" nil t)) + t) + "Is non-nil when Emacs packages are installed by GNU/Guix package manager.") + +(defun jd/add-package-to-manifest (guix-package-name) + "Add GUIX-PACKAGE-NAME to jd/manifest-list." + (unless (member guix-package-name jd/manifest-list) + (setq jd/manifest-list + (cons guix-package-name jd/manifest-list)))) + +(add-to-list 'load-path (concat user-emacs-directory "/jd")) + +(defun jd/display-startup-time () + (message "Emacs loaded in %s with %d garbage collections." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done)) + +(defun jd-emacs/startup () + "This procedure will run after Emacs startup." + (electric-pair-mode 1) + (global-company-mode 1) + (jd/display-startup-time)) + +(add-hook 'emacs-startup-hook #'jd-emacs/startup) + +(setq user-full-name "Jakub Dlugosz" + user-mail-address "jdlugosz963@gmail.com") + +(setq backup-directory-alist '(("." . "~/.cache/emacs/backup")) + backup-by-copying t + version-control t + delete-old-versions t + kept-new-versions 20 + kept-old-versions 5 + custom-file (concat user-emacs-directory + "custom.el")) + +;; (setq user-emacs-directory "~/.cache/emacs") + +(require 'package) +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("org" . "https://orgmode.org/elpa/") + ("gnu-devel" . "https://elpa.gnu.org/devel/") + ("elpa" . "https://elpa.gnu.org/packages/"))) +(package-initialize) + +(unless package-archive-contents + (package-refresh-contents)) + +(jd/add-package-to-manifest "emacs-use-package") +(unless jd/guix-p + (unless (package-installed-p 'use-package) + (package-install 'use-package))) + +(require 'use-package) + +(setq use-package-always-ensure (not jd/guix-p)) + +(defun jd/generate-manifest () + "Generate GNU/Guix Emacs manifest to temp-buffer." + (interactive) + (with-output-to-temp-buffer "*guix-emacs-packages-manifest.scm*" + (princ (concat ";; This file is auto-generated by Emacs " + "function: jd/manifest-generate-to-file \n")) + (princ `(specifications->manifest + '(,@(mapcar #'(lambda (guix-package-name) + (concat "\"" + guix-package-name + "\"\n")) + jd/manifest-list)))))) + +(defun use-package-normalize/:guix-package (name keyword args) + (use-package-as-one (symbol-name keyword) args + #'(lambda (_label arg) + (cond + ((consp arg) arg) + ((stringp arg) (list arg)) + ((use-package-non-nil-symbolp arg) (symbol-name arg)) + (t + (use-package-error + ":pin wants an archive name (a string)")))))) + +(defun use-package-handler/:guix-package + (name _keyword args rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + (when (consp args) + (mapcar #'(lambda (arg) + `(jd/add-package-to-manifest ,arg)) + args)) + body))) + +(add-to-list 'use-package-keywords ':guix-package) + +(jd/add-package-to-manifest "emacs") +(jd/add-package-to-manifest "emacs-guix") + +(require 'jd-keys) +(require 'jd-ui) +(require 'jd-org) +(require 'jd-dev) +(require 'jd-apps) +(require 'jd-custom) +(require 'jd-mu4e) +(require 'jd-misc) +(require 'jd-sway) + +(when jd/exwm-p + (require 'jd-exwm)) + +;; (setq gc-cons-threshold (* 2 1000 1000)) + +;;; init.el ends here +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(put 'set-goal-column 'disabled nil) -- cgit v1.2.3