From 7bcf1bf5d207129ee531c5ee31c46aa125a9f16c Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:22:57 -0600 Subject: [PATCH 01/16] etangle: check for file readability So now ignore if there are missing/unreable files in USEROPTS. --- etangle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etangle b/etangle index 7e15621..eefb555 100755 --- a/etangle +++ b/etangle @@ -10,7 +10,8 @@ (if (getenv "USEROPTS") (dolist (fnam (split-string (getenv "USEROPTS") ":")) (if (not (member fnam '("" nil))) - (load-file (concat "./options/" fnam ".el")) + (if (file-readable-p (concat "./options/" fnam ".el")) + (load-file (concat "./options/" fnam ".el"))) )) ) From a7ed4f8c1394d4cf46257349ca826cd6f2e986a6 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:40:07 -0600 Subject: [PATCH 02/16] Makefile: Use scutil for hostname on osx Works around stuff like vpn dns setting its own hostname and hostname -s to return that dns name verus the configured name for the mac. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 623f1dd..ae8cca1 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,10 @@ LASTGEN:=$(PWD)/generation/$(LAST) TANGLERS:=$(shell ls -d *.org) GEN:=$(LAST) OPTS:= -# OSX uses hostname -s for the "stable" hostname -# uname -n can return dhcp addresses, which aren't -# stable. -HOST=$(shell echo "$$(hostname -s || uname -n)") +# OSX uses scutil --get ComputerName +# uname -n && hostname -s can return dhcp addresses +# which aren't stable. +HOST=$(shell echo "$$(scutil --get ComputerName || uname -n)") USEROPTS:=$(OPTS):$(HOST) NAME:=default From ee9e159b8dfc202cb5edaa0c39a211f81126ec37 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:41:33 -0600 Subject: [PATCH 03/16] emacs.org: Pylint is a PITA if it breaks, disable it for now --- emacs.org | 1 - 1 file changed, 1 deletion(-) diff --git a/emacs.org b/emacs.org index 14bcfbd..53d0623 100644 --- a/emacs.org +++ b/emacs.org @@ -1242,7 +1242,6 @@ TODO: fixme (add-hook 'python-mode-hook '(lambda () (flycheck-select-checker 'python-flake8) - (flycheck-select-checker 'python-pylint) ) ) From 3693e32766ae4f53ca9d8b002fe8a2e1d79451b9 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:43:20 -0600 Subject: [PATCH 04/16] haskell.org: Get rid of ~/.ghc.hs It... is not the best idea between haskell versions. --- haskell.org | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/haskell.org b/haskell.org index 03e3791..d95495a 100644 --- a/haskell.org +++ b/haskell.org @@ -19,18 +19,3 @@ Ghci setup, mostly just cosmetics. :set prompt "λ " :set +t #+END_SRC - -* ~/.ghc.hs - -What to automatically have loaded into ghci sessions. - -#+BEGIN_SRC haskell :tangle tmp/.ghc.hs -import Control.Applicative -import Control.Monad -import Data.Monoid -import Data.Maybe -import Data.List -import Data.Bool -import qualified Data.Set as S -import qualified Data.Map as M -#+END_SRC From bacc4dc048ee6ebbe5ac49b3ba7ad032040e873a Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:44:50 -0600 Subject: [PATCH 05/16] tmux.org: Remove set-remain-on-exit No longer applicable to recent tmux past 2.4..ish. Too lazy to look it up. --- tmux.org | 3 --- 1 file changed, 3 deletions(-) diff --git a/tmux.org b/tmux.org index 549272a..f92aaca 100644 --- a/tmux.org +++ b/tmux.org @@ -118,9 +118,6 @@ Tmux configuration. Pretty boring in most ways. # Non confirming kill pane plskthxbai bind-key x kill-pane - # In case something I run exits straight away, i'd like to know about it. - set-option -g set-remain-on-exit on - # Lets change the prefix key so we don't clobber emacs back one char key unbind-key C-b From 1b18e232a3aae0689f2d102a39d993622570d9c9 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:46:28 -0600 Subject: [PATCH 06/16] tmux.org: Make tmux selection color be red bg, black fg --- tmux.org | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tmux.org b/tmux.org index f92aaca..6df2b8d 100644 --- a/tmux.org +++ b/tmux.org @@ -24,6 +24,9 @@ Tmux configuration. Pretty boring in most ways. set-window-option -g window-status-fg black set-window-option -g window-status-current-bg white + # Selection highlight color + set-window-option -g mode-style bg=red,fg=black + # Status line options set-option -g status-bg black set-option -g status-fg colour7 From 6debb6ff080df0c8de92b6a2007ef72c2a212f4f Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:47:15 -0600 Subject: [PATCH 07/16] bin.org: Fix a babel error --- bin.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin.org b/bin.org index f3df813..b758d73 100644 --- a/bin.org +++ b/bin.org @@ -17,7 +17,7 @@ A stupid script I wrote ages ago to help me be lazy with cidr notation for stuff. Setup the wrong netmask a few times and you too, will wish for something similar. -#+BEGIN_SRC perl :padline no :tangle tmp/bin/cidr:padline no +#+BEGIN_SRC perl :padline no :tangle tmp/bin/cidr #!/usr/bin/env perl # # Convert input ip/cidr|netmask|hexnetmask to useable network information. From e6e50e517ee92a71ace541f5176470fbf699febc Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:48:40 -0600 Subject: [PATCH 08/16] bin.org: Update nix configuration to work other channels --- bin.org | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin.org b/bin.org index b758d73..d4b9593 100644 --- a/bin.org +++ b/bin.org @@ -1018,14 +1018,19 @@ More for nix on macos, but just merges NixOS/nipkgs origin/master to the current set -e session=nix + PKGS=${PKGS:-nixpkgs} - cd ~/src/github.com/NixOS/nixpkgs + if "${PKGS}" != "nixpkgs"; then + cd ~/src/github.com/NixOS/nixpkgs/${PKGS} + else + cd ~/src/github.com/NixOS/nixpkgs + fi if ! tmux has-session -t ${session}; then tmux new-session -d -s ${session} -n nix tmux send-keys -t ${session}:0 'sleep 30 while true; do - blah=$(nix-env -iA --dry-run stdboth nixpkgs.default | grep /nix); echo "${blah}" | head -n $(echo "$LINES - 2" | bc); echo "${blah}" | grep -c /nix | ts + blah=$(nix-env -f "<${PKGS}>" -iA --dry-run stdboth default | grep /nix); echo "${blah}" | head -n $(echo "$LINES - 2" | bc); echo "${blah}" | grep -c /nix | ts echo "${blah}" | grep /nix > /dev/null 2>&1 if [ $? -eq 0 ]; then sleep 60 @@ -1036,14 +1041,12 @@ More for nix on macos, but just merges NixOS/nipkgs origin/master to the current done ' C-m tmux split-window -v -t ${session}:0 - tmux send-keys -t ${session}:0.1 'git fetch --all && git merge origin/master && - time nix-env -iA nixpkgs.default && nix-env -u --leq && exit 0 + tmux send-keys -t ${session}:0.1 'git fetch --all && git short HEAD > last-$(iso8601) && git rebase --autostash origin/staging && + time nix-env -f "<${PKGS}>" -iA default && nix-env -f "<${PKGS}>" -u --leq && exit 0 ' C-m tmux select-window -t ${session}:0 fi tmux attach -t ${session} - - #+END_SRC * ~/bin/notify From 802d644194d81c41a167d2d2103ed3da11650b2b Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:50:42 -0600 Subject: [PATCH 09/16] nix.org: New year cleaning of some default derivations --- nix.org | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/nix.org b/nix.org index ad2fb41..b529147 100644 --- a/nix.org +++ b/nix.org @@ -22,11 +22,10 @@ Nix user config.nix setup. name = "default"; ignoreCollisions = true; paths = [ - ack aria aspell aspellDicts.en - bazaarTools + cabal-install cacert clang clang-analyzer @@ -41,7 +40,6 @@ Nix user config.nix setup. duply emacs entr - gcc gdbm ghostscript gist @@ -55,12 +53,10 @@ Nix user config.nix setup. gnutls graphviz-nox haskellPackages.ShellCheck - haskellPackages.cabal-dependency-licenses haskellPackages.ghc-mod haskellPackages.hasktags haskellPackages.hindent haskellPackages.hspec - haskellPackages.idris haskellPackages.pandoc htop imagemagick @@ -74,11 +70,8 @@ Nix user config.nix setup. moreutils mosh mr - multimarkdown multitail munge - mutt - nox openssl p7zip patchutils @@ -98,7 +91,6 @@ Nix user config.nix setup. rtags silver-searcher sloccount - sqlite sshpass stack texlive.combined.scheme-full From eff9fb810b73074e52bed9e82c2875aecbc9a9eb Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 12:58:18 -0600 Subject: [PATCH 10/16] dotprofile.org: Setup nix with nixpkgs and staging Just correspond with nixpkgs master and staging. More to likely come. --- dotprofile.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotprofile.org b/dotprofile.org index b76f5b4..e63c2b6 100644 --- a/dotprofile.org +++ b/dotprofile.org @@ -262,7 +262,7 @@ nix_env_setup() # BAD INSTALLER NO COOKIE! if [ -e ${HOME}/.nix-profile/etc/profile.d/nix.sh ]; then . ${HOME}/.nix-profile/etc/profile.d/nix.sh; - export NIX_PATH=${HOME}/src/github.com/NixOS/nixpkgs:nixpkgs=${HOME}/src/github.com/NixOS/nixpkgs + export NIX_PATH=nixpkgs=${HOME}/src/github.com/NixOS/nixpkgs:staging=${HOME}/src/github.com/NixOS/nixpkgs/staging export NIX_CFLAGS_COMPILE="-idirafter /usr/include" export NIX_CFLAGS_LINK="-L/usr/lib" export PKG_CONFIG_PATH="~/.nix-profile/lib/pkgconfig" From d78eaa6f2ac9285af585245cec1ea2abe9563d19 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 13:23:40 -0600 Subject: [PATCH 11/16] tmux.org: Testing out a battery meter hidden behind testing-p --- tmux.org | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tmux.org b/tmux.org index 6df2b8d..738286d 100644 --- a/tmux.org +++ b/tmux.org @@ -151,3 +151,20 @@ Only set xclip for x setup. bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer" bind C-y run "tmux save-buffer - | xclip -i" #+END_SRC + +Testing of battery stuff, defaults in general. + +#+BEGIN_SRC conf :tangle (tangle/file ".tmux.conf" (and (bound-and-true-p tmux-p) (bound-and-true-p testing-p))) + set-option -g status-right-length 21 + set-option -g status-right "#{battery_status_fg}#{battery_remain} #{battery_icon}#[fg=white] %a %H:%M:%S" + set-option -g @batt_charged_icon "✓" + run-shell ~/src/github.com/tmux-plugins/tmux-battery/battery.tmux +#+END_SRC + +And for macos, differ in that the battery charged icon is utf-8 really. TODO: do I need this really? + +#+BEGIN_SRC conf :tangle (tangle/file ".tmux.conf" (and (bound-and-true-p testing-p) (bound-and-true-p tmux-p) (bound-and-true-p macos-p))) + set-option -g status-right-length 20 + set-option -g status-right "#{battery_remain} #{battery_icon} %a %H:%M:%S" + run-shell ~/src/github.com/tmux-plugins/tmux-battery/battery.tmux +#+END_SRC From 5e2cd382f73d03f59c9c9af8ce9b40eecd8cf5ec Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 13:24:27 -0600 Subject: [PATCH 12/16] options/default-macos.el: Initial commit for macos options For sym/hard-linking a hostname link to. --- options/default-macos.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 options/default-macos.el diff --git a/options/default-macos.el b/options/default-macos.el new file mode 100644 index 0000000..1234d0b --- /dev/null +++ b/options/default-macos.el @@ -0,0 +1,14 @@ +;;-*-mode: emacs-lisp; coding: utf-8;-*- +;; File: default-macos.el +;; Copyright: 2017 Mitch Tishmack +;; Description: default options for macos +(setq testing-p t) +(setq macos-p t) +(setq nix-p t) +(setq tmux-p t) +(setq git-p t) +(setq emacs-p t) +(setq zsh-p t) +(setq mosh-p t) +(setq haskell-p t) +(setq perl-p t) From 4fed1aeaf0382eedd5b55879ff987607b05ab5ee Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 13:25:26 -0600 Subject: [PATCH 13/16] options/[no-]testing.el: Initial commit for testing-p predicate --- options/no-testing.el | 1 + options/testing.el | 1 + 2 files changed, 2 insertions(+) create mode 100644 options/no-testing.el create mode 100644 options/testing.el diff --git a/options/no-testing.el b/options/no-testing.el new file mode 100644 index 0000000..57196d7 --- /dev/null +++ b/options/no-testing.el @@ -0,0 +1 @@ +(setq testing-p nil) diff --git a/options/testing.el b/options/testing.el new file mode 100644 index 0000000..0f7b57b --- /dev/null +++ b/options/testing.el @@ -0,0 +1 @@ +(setq testing-p t) From 50463ceacf1f5d6b19780465e27e71a5c563636d Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 13:44:33 -0600 Subject: [PATCH 14/16] readme.org: M-q all the things, document make option NAME=thing Minor verbiage fixes, me fail english? Thats unpossible. I only speak two languages, english and bad english. --- readme.org | 106 ++++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/readme.org b/readme.org index 7d08ce1..1069ffe 100644 --- a/readme.org +++ b/readme.org @@ -5,29 +5,29 @@ #+BABEL: :cache yes #+PROPERTY: header-args :tangle yes :cache yes :comments no :padline no -In the long long ago (2015), I used xstow and update-dotdee to construct my -dotfiles from tiny pieces of files. +In the third age of my dotfile setup (2015), I used xstow and update-dotdee to +construct my dotfiles from tiny pieces of files as a sort of mini templating +engine. -I have since evolved to this setup. Originally the intention was to make it -easy for me to compile dotfiles based on certain parameters. Aka, my dotfiles -are the same for x, y, and z, whatever those are, but for certain cases z -should have one section be different or added etc... as the case may be. +I have since evolved to this setup. Originally the intention was to make it easy +for me to compile dotfiles based on certain parameters. Aka, my dotfiles are the +same for x, y, and z, whatever those are, but for certain cases z should have +one section be different or added etc... as the case may be. Aka it was just a glorified program or templating system. -Since I already use org-mode to build my emacs configuration, -why not just do the same for the dotfiles. Bonus, now I can have ALL -my dotfiles in one logical file that can build itself. +Since I already use org-mode to build my emacs configuration, why not just do +the same for the dotfiles. Bonus, now I can have ALL my dotfiles in one logical +file that can build itself. -So now if you want to look at my dotfiles, they're all in here. With one -caveat that my emacs configuration is not. That is still separate. Mostly -because it is large enough that it can stand on its own. +So now if you want to look at my dotfiles, they're all in here. With one caveat +that my emacs configuration is not. That is still separate. Mostly because it is +large enough that it can stand on its own. * Use/Abuse -Use of this setup is somewhat simple or straightforward. - -There really is one step in general: +Use of this setup is somewhat simple or straightforward. There really is one +step in general: #+BEGIN_SRC sh :tangle no make @@ -35,9 +35,9 @@ There really is one step in general: ** Emacs functions to add to init.el -For all this to work in emacs so you can edit source blocks you'll need -add the following two functions otherwise you'll get an error every time -you try to edit the source block. +For all this to work in emacs so you can edit source blocks you'll need add the +following two functions otherwise you'll get an error every time you try to edit +the source block. #+BEGIN_SRC emacs-lisp :tangle no (defun tangle/yn (p) (if (bound-and-true-p p) "yes" "no")) @@ -46,9 +46,9 @@ you try to edit the source block. This is also all the "magique" that this whole stupid repo entails. -But how would you control how things get exported? Well that is done -via files with simple *(setq predicate-p t)* lines inside them. These -are all the *options/name.el* files comprise of. +But how would you control how things get exported? Well that is done via files +with simple *(setq predicate-p t)* lines inside them. These are all the +*options/name.el* files comprise of. But lets say you want to export things to another directory than $HOME. No worries, just specify DEST: @@ -67,6 +67,12 @@ echo "(setq ${name}-p t)" > options/${name}.el echo "(setq ${name}-p nil)" > options/no-${name}.el #+END_SRC +Or, more easily/lazily using the option makefile target: + +#+BEGIN_SRC sh :tangle no +make option NAME=predicate-name-without-p +#+END_SRC + And then provide the *name* (without the .el extension) to make via *OPTS*: #+BEGIN_SRC sh :tangle no @@ -83,12 +89,12 @@ Etc... I wouldn't do this exactly, while you could, thats just too much to need to remember to type. The simplest way to do things is to just create an -*options/$(uname -n).el* file with all the options you need defined. Note that -in the or *BEGIN_SRC* lines you can use elisp to control when/how something should or +*options/$(uname -n).el* file with all the options you need defined. Note that in +the or *BEGIN_SRC* lines you can use elisp to control when/how something should or should not get tangled. -Example use of tangle/file, note the final option is just elisp and we just -use *bound-and-true-p* to detect if we have a predicate or not. +Example use of tangle/file, note the final option is just elisp and we just use +*bound-and-true-p* to detect if we have a predicate or not. #+BEGIN_SRC emacs-lisp :tangle no (tangle/file "some/file/name" (bound-and-true-p macos-p)) @@ -113,12 +119,12 @@ installing to some *DEST*, and want to copy that to *$HOME*? No worries: Where N is the generation you want to copy. -Note, to ensure this doesn't by default overwrite hand edited files, a -diff is run across the files that would be copied to and what the tangled -version contains. +Note, to ensure this doesn't by default overwrite hand edited files, a diff is +run across the files that would be copied to and what the tangled version +contains. -Example, I've commented out some .gitignore lines in *~/.gitignore* manually -and then tried to tangle a new generation over the top. +Example, I've commented out some .gitignore lines in *~/.gitignore* manually and +then tried to tangle a new generation over the top. #+BEGIN_SRC sh :tangle no ./ddiff /Users/me/src/github.com/mitchty/dotfiles/generation/291 /Users/me @@ -138,28 +144,28 @@ differences between /Users/me/src/github.com/mitchty/dotfiles/generation/291 and #+END_SRC This is an attempt to ensure that we don't accidentally overwrite files that may -have customizations on it. +have manual customizations in them. -To force it just run *make copy GEN=N* with *N* as the number to force a copy for. +To forcibly overwrite the files just run *make copy GEN=N* with *N* as the number to +force overwriting the destination files. ** How does it work? -It is really rather simple, the [[file:Makefile][Makefile]] isn't that complex. Look at that -for details. +It is really rather simple, the [[file:Makefile][Makefile]] isn't that complex. Look at that for +details. -This isn't intended to cover everything. This could be considered a template -for how you could setup your files in a similar way. Look at this org mode -file for details. +This isn't intended to cover everything. This could be considered a template for +how you could setup your files in a similar way. Look at this org mode file for +details. -NOTE: Removal of files is YOUR job, not this tools. One could -theoretically look at what changed between two generations and -remove that way. BUT that sounds janky and error prone. Removal of -files is the users job, not this setup. +NOTE: Removal of files is YOUR job, not this tools. One could theoretically look +at what changed between two generations and remove that way. BUT that sounds +janky and error prone. Removal of files is the users job, not this setup. ** Explanation of what is happening -This allows me to tangle files that would be useful for linux/bsd/etc... -without affecting the existing files. +This allows me to tangle files that would be useful for linux/bsd/etc... without +affecting the existing files. The general idea is this (look at Makefile for details): - increment generation count from last generation @@ -173,14 +179,14 @@ The general idea is this (look at Makefile for details): - Update last with current generation. Note, the destination can be anywhere, not just $HOME. This allows one to -compile/tangle files that can then be trivially rsynced to remote machines, -or to tar/xz the files as needed. The key here is emacs is only required -to generate config files, not necessarily to use them. +compile/tangle files that can then be trivially rsynced to remote machines, or +to tar/xz the files as needed. The key here is emacs is only required to +generate config files, not necessarily to use them. ** How would I use this? -Should be easy enough to either clone this repo or copy things to a new repo -and hack in what you need. Your call. +Should be easy enough to either clone this repo or copy things to a new repo and +hack in what you need. Your call. But, say you have a heading, take .profile as an example, under an org mode heading you would just add to your *BEGIN_SRC* definition like so: @@ -196,8 +202,8 @@ that you put everything into *tmp*! This is used to generate things before a generation is built. It gives the Makefile a chance to know if the tangling worked or not. -But lets say you don't need to have lots of sub headings, or even control -a file in multiple subparts that have predicates to control things. +But lets say you don't need to have lots of sub headings, or even control a file +in multiple subparts that have predicates to control things. Pretty simple, just add a source block like normal: #+BEGIN_SRC text :tangle no From 3ec88a14a227c6f173352d0d8052ce1734eb6ee9 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 13:55:16 -0600 Subject: [PATCH 15/16] readme.org: Everything is not in the readme.org file anymore. --- readme.org | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/readme.org b/readme.org index 1069ffe..078026a 100644 --- a/readme.org +++ b/readme.org @@ -17,12 +17,9 @@ one section be different or added etc... as the case may be. Aka it was just a glorified program or templating system. Since I already use org-mode to build my emacs configuration, why not just do -the same for the dotfiles. Bonus, now I can have ALL my dotfiles in one logical -file that can build itself. +the same for the dotfiles. -So now if you want to look at my dotfiles, they're all in here. With one caveat -that my emacs configuration is not. That is still separate. Mostly because it is -large enough that it can stand on its own. +So now if you want to look at my dotfiles, they're all here. * Use/Abuse From 5ff14c8d3f7826b42722e33a2b7e0bffcc61e5a5 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Sun, 31 Dec 2017 15:10:57 -0600 Subject: [PATCH 16/16] Makefile: Add removed target Lets you list out what files were removed from OLD to NEW generations. Note automatically done to remove files as I consider that the job of the user. While here, added a function check_defined to let me check if a variable is defined or not and if not bail. Updated the option target to use this function as well as the removed target where I needed it for. --- Makefile | 34 +++++++++++++++++++++++++++------- readme.org | 28 +++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index ae8cca1..5e36d91 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,31 @@ # Makefile is here to make it possible to use this whole shebang # outside of emacs. +# +# TODO: wrap this stuff into a script maybe? DEST:=$(HOME) -LAST:=$(shell cat .last || echo 0) -NEXT:=$(shell l=$(LAST); ((l=l+1)); echo $$l) +LAST!=cat .last || echo 0 +NEXT!=l=$(LAST); ((l=l+1)); echo $$l NEXTGEN:=$(PWD)/generation/$(NEXT) LASTGEN:=$(PWD)/generation/$(LAST) -TANGLERS:=$(shell ls -d *.org) +TANGLERS:=$(wildcard *.org) GEN:=$(LAST) OPTS:= # OSX uses scutil --get ComputerName # uname -n && hostname -s can return dhcp addresses # which aren't stable. -HOST=$(shell echo "$$(scutil --get ComputerName || uname -n)") +HOST!=scutil --get ComputerName || uname -n USEROPTS:=$(OPTS):$(HOST) -NAME:=default + +# Make it easier to check if a variable is defined or not +# params: +# variable name +# optional message to print if variable is not set +check_defined = \ + $(strip $(foreach 1,$1, \ + $(call __check_defined,$1,$(strip $(value 2))))) +__check_defined = \ + $(if $(value $1),, \ + $(error Undefined variable $1$(if $2, ($2)))) INSTALLDIRS=tmp $(NEXTGEN) $(LASTGEN) generation/$(GEN) @@ -25,8 +37,6 @@ $(INSTALLDIRS): generation: $(NEXTGEN) $(LASTGEN) tmp cd tmp && cp -av . $(NEXTGEN) -check: - diff: generation/$(GEN) ./ddiff $(PWD)/generation/$(GEN) $(DEST) @@ -50,6 +60,15 @@ copy: tangle: tmp USEROPTS=$(USEROPTS) /usr/bin/env emacs --script ./etangle $(TANGLERS) +# TODO: is this gnu diff output... only or not? note: wip until i've +# tested on bsd make etc... + +.PHONY: removed +removed: + $(call check_defined, OLD, generation to compare removed files against) + $(call check_defined, NEW, generation to compare removed files to) + @diff -bur generation/$(OLD) generation/$(NEW) 2>&1 | grep 'Only in generation/'$(OLD) | sed -e 's|Only in ||' -e 's|.*[:] ||' + clean: -rm -fr tmp @@ -58,5 +77,6 @@ nuke: clean .PHONY: option option: + $(call check_defined, NAME, predicate NAME to define in option files. Note: without -p i.e. NAME-p = t and no-NAME-p = nil) echo "(setq $(NAME)-p t)" > options/$(NAME).el echo "(setq $(NAME)-p nil)" > options/no-$(NAME).el diff --git a/readme.org b/readme.org index 078026a..280b274 100644 --- a/readme.org +++ b/readme.org @@ -155,9 +155,31 @@ This isn't intended to cover everything. This could be considered a template for how you could setup your files in a similar way. Look at this org mode file for details. -NOTE: Removal of files is YOUR job, not this tools. One could theoretically look -at what changed between two generations and remove that way. BUT that sounds -janky and error prone. Removal of files is the users job, not this setup. +** Removal of files between generations + +Removal of files is ultimately *YOUR* job. However... to make it possible to +remove things if desired a bit easier you can run this makefile target with the +*OLD* and *NEW* variables set: + +#+BEGIN_SRC sh :tangle no +make removed OLD=generation NEW=generation +#+END_SRC + +This will list all the files/directories recursively not in *OLD* compared to *NEW*. + +Example: + +#+BEGIN_SRC sh :tangle no +$ make removed OLD=40 NEW=470 +.Xdefaults +.Xresources +.ghc.hs +escp +essh +flushdns +tomod +towip +#+END_SRC ** Explanation of what is happening