home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 80bd0cee7ec1c12df8bbb956b4439a1f7b08e652
parent 8f4542c282cb2830001745fc1d66af53c37065f9
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Wed, 19 Feb 2020 17:20:17 +0100

emacs.org: trying somethings…

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Aemacs.org | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+), 0 deletions(-)

diff --git a/emacs.org b/emacs.org @@ -0,0 +1,108 @@ +#+SETUPFILE: ../_setup.org +#+TITLE: Vincent Demeester's .emacs.d + +* Overview +:PROPERTIES: +:CUSTOM_ID: h:d95d2079-2aee-4be4-b6bd-d89de96e7033 +:END: + +** Canonical links to this document +:PROPERTIES: +:CUSTOM_ID: h:0a080da3-bcc6-42a1-83ef-5d1ed6123cc4 +:END: + +** What is this +:PROPERTIES: +:CUSTOM_ID: h:fa787d18-1a0c-4312-bc07-22318c645daa +:END: + +This is a try at merging [[https://github.com/vdemeester/emacs-config.git][~vdemeester/emacs-config~]] and [[https://github.com/vdemeester/home.git][~vdemeester/home~]] repository by +having the emacs configuration written in there. Once this is complete, +[[https://github.com/vdemeester/emacs-config.git][~vdemeester/emacs-config~]] should be archived. + +* Nix-ies +:PROPERTIES: +:CUSTOM_ID: h:8bc69da9-b49c-4ddd-a6c9-b944aad993a1 +:END: + +This is where the magic happens, when using [[https://nixos.org/nix/][~nix~]] or [[https://nixos.org][NixOS]] with [[https://github.com/rycee/home-manager][~home-manager~]]. In a gist +we will create a set of nix files that tangle, get dependencies and generate the correct +emacs package with the packages used inside the configuration. This means, if I add a +=(use-package magit)= in my configuration, and I tangle / re-execute this script(s), I now +have a new packaged installed as part of my Emacs package. This is *heavily* inspired by +[[https://matthewbauer.us/bauer/][Matthew Bauer's bauer]] emacs configuration. + +** Required lisp libraries +:PROPERTIES: +:CUSTOM_ID: h:316fd3ee-ab99-4f01-ba5a-1a91c54bc334 +:END: + +We need a way to list packages used in the configuration using ~use-package~. This is +coming straight from [[https://matthewbauer.us/bauer/][Matthew Bauer's bauer]]. + +#+begin_src emacs-lisp :tangle ~/.emacs.d/lisp/use-package-list.el +;;; use-package-list.el --- List use-package declarations in config file + +;; Copyright (C) 2017 Matthew Bauer + +;; Author: Matthew Bauer <mjbauer95@gmail.com> + +;; This file is NOT part of GNU Emacs. + +;;; Commentary: + +;; ‘ensure’ packages at compile time. + +;;; Code: + +(require 'json) +(require 'use-package) +(require 'package) +(eval-when-compile + (require 'cl)) + +(defun use-package-list (script) + "Count use-package declarations listed in SCRIPT." + + (defvar use-package-list--is-running t) + (lexical-let ((use-package-verbose t) + (use-package-debug t) + (use-package-always-ensure nil) + (use-package-always-defer t) + (use-package-list--packages nil) + (use-package-ensure-function 'ignore)) + (advice-add 'use-package + :before (lambda (name &rest args) + (unless (or (and (member :disabled args) + (plist-get args :disabled)) + (and (member :ensure args) + (not (plist-get args :ensure))) + (and (not (member :ensure args)) + (package-built-in-p name))) + (when (and (member :ensure args) + (not (eq (plist-get args :ensure) t)) + (symbolp (plist-get args :ensure))) + (setq name (plist-get args :ensure))) + (add-to-list 'use-package-list--packages name)))) + + (advice-add 'use-package-handler/:defer + :around (lambda (x name keyword arg rest state) + (let ((body (use-package-process-keywords name rest + (plist-put state :deferred t))) + (name-string (use-package-as-string name))) + (dolist (command + (delete-dups (plist-get state :commands))) + (fset command (lambda (&rest args)))) + body))) + + (advice-add 'use-package-load-name :override #'ignore) + + (load script nil nil t) + + (princ (json-encode use-package-list--packages)) + + use-package-list--packages)) + +(provide 'use-package-list) +;;; use-package-list.el ends here +#+end_src