From 67f57101e869555bec08ec943f688e63a18d1506 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 24 Jan 2015 23:58:03 +0900 Subject: [PATCH] Use SETUP_LOAD #4 --- Makefile | 32 ++++++++++++++++++++++++++------ emacs.el | 4 ++-- setup.sh | 1 + tmux.conf | 1 + vimrc | 6 +++--- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a560974..f934c88 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ shrc_common_tpl = emacs ?= $(shell which emacs 2>/dev/null) git ?= $(shell which git 2>/dev/null) curl ?= $(shell which curl 2>/dev/null) +grep ?= GREP_OPTIONS= $(shell which grep 2>/dev/null) # Targets @@ -44,8 +45,9 @@ test_syntaxes = test-syntax-el test-syntax-sh test-syntax: $(test_syntaxes) setups = setup-darwin setup-directories setup-emacs setup-gitconf \ - setup-repository setup-util setup-tmux -setup: $(setups) + setup-repository setup-util setup-rc +# `make setup` to setup these all sounds to be too match +setup-all: $(setups) @@ -112,7 +114,9 @@ endif # setup repository # ---------------- -setup-repository: +setup-repository: $(dotfiles_dir)/.git + +$(dotfiles_dir)/.git: ifeq (,$(git)) false "Git not installed" endif @@ -264,13 +268,29 @@ endif -# tmux setup -# ---------- +# setup rc files +# -------------- + +setup_rcs = setup-rc-vimrc setup-rc-tmux.conf setup-rc-emacs.el +setup-rc: $(setup_rcs) +.PHONY: $(setup_rcs) -setup-tmux: +command_extract_setup_load = $(grep) -e 'SETUP_LOAD: ' | \ + sed -e 's/^.*SETUP_LOAD: //' -e 's|DOTFILES_DIR|$(dotfiles_dir)|' +$(setup_rcs): setup-rc-%: $(dotfiles_dir)/% +ifeq (,$(append_load)) + @echo "\`append_load' is not defined. Just print load command." + cat "$<" | $(command_extract_setup_load) +else + cat "$<" | $(command_extract_setup_load) | tee -a "$(topfile)" +endif +setup-rc-vimrc: topfile = $(home)/.vimrc +setup-rc-tmux.conf: topfile = $(home)/.tmux.conf +setup-rc-emacs.el: topfile = $(home)/.emacs.d/init.el +$(dotfiles_dir)/%: setup-repository # test diff --git a/emacs.el b/emacs.el index 3fbadbe..9c070cb 100644 --- a/emacs.el +++ b/emacs.el @@ -4,8 +4,8 @@ ;;; Code: -;; (and (file-readable-p "~/.dotfiles/emacs.el") -;; (load-file "~/.dotfiles/emacs.el")) +;; SETUP_LOAD: (and (file-readable-p "DOTFILES_DIR/emacs.el") +;; SETUP_LOAD: (load-file "DOTFILES_DIR/emacs.el")) ;; make directories (unless (file-directory-p (expand-file-name user-emacs-directory)) diff --git a/setup.sh b/setup.sh index 83a2835..b5df98c 100755 --- a/setup.sh +++ b/setup.sh @@ -292,6 +292,7 @@ __EOC__ } ############################## + # setup scripts _fetch_script(){ diff --git a/tmux.conf b/tmux.conf index fcd9add..2d719df 100644 --- a/tmux.conf +++ b/tmux.conf @@ -1,4 +1,5 @@ # tmux.conf +# SETUP_LOAD: source "DOTFILES_DIR/tmux.conf" run-shell 'tmux set -g status-right "${USER}@`hostname` | #(tmux -V) "' diff --git a/vimrc b/vimrc index a94e68e..b932d5c 100644 --- a/vimrc +++ b/vimrc @@ -1,7 +1,7 @@ " "load external file -" if filereadable(expand('~/.dotfiles/vimrc')) -" source ~/.dotfiles/vimrc -" endif +" SETUP_LOAD: if filereadable(expand('DOTFILES_DIR/vimrc')) +" SETUP_LOAD: source DOTFILES_DIR/vimrc +" SETUP_LOAD: endif if !isdirectory(expand('~/.vim')) call mkdir(expand('~/.vim')) endif