Procházet zdrojové kódy

Merge pull request #5 from 10sr/runTarget

Run target
pull/15/head
10sr před 9 roky
rodič
revize
673ff27a2c
2 změnil soubory, kde provedl 100 přidání a 76 odebrání
  1. +65
    -47
      Makefile
  2. +35
    -29
      emacs.el

+ 65
- 47
Makefile Zobrazit soubor

@@ -3,8 +3,6 @@

# Variable definitions

home ?= $(HOME)

dotfiles_url_base := https://raw.githubusercontent.com/10sr/dotfiles/master
use_git ?= t
git_auth ?= t
@@ -32,7 +30,7 @@ ifeq (,$(dotfiles_dir))
ifeq (,$(DOTFILES_DIR))
$(warning Neigher DOTFILES_DIR nor dotfiles_dir is defined)
$(warning Use default value)
dotfiles_dir := $(home)/10sr_dotfiles
dotfiles_dir := $(HOME)/10sr_dotfiles
else
# dotfiles_dir is empty but DOTFILES_DIR has a value
$(warning dotfiles_dir is set from DOTFILES_DIR)
@@ -46,9 +44,23 @@ endif
$(warning dotfiles_dir: $(dotfiles_dir))


ifeq ($(home),)
ifeq ($(global_home),)
$(warning home not set and global_home is empty)
# TODO: What this should be?
home := $(dotfiles_dir)/.home
else
home := $(HOME)
endif
endif
$(warning home: $(home))


localdir := $(home)/.local
vardir := $(home)/.var
bindir := $(localdir)/bin
directories := $(dotfiles_dir) $(home) $(localdir) $(vardir) $(bindir) \
$(home)/.emacs.d

current := $(shell date)
uname := $(shell uname)
@@ -60,6 +72,8 @@ git ?= $(shell which git 2>/dev/null)
curl ?= $(shell which curl 2>/dev/null)
grep ?= GREP_OPTIONS= $(shell which grep 2>/dev/null)

files := Makefile emacs.el profile shrc tmux.conf vimrc _keysnail.js

# Targets

all: default
@@ -76,6 +90,9 @@ setups := setup-darwin setup-directories setup-emacs setup-gitconf \
setup-all: $(setups)


runs := run-emacs run-bash run-zsh



# `make check` is just an alias for `make test`
check: test
@@ -90,6 +107,10 @@ check-syntax: test-syntax



$(directories):
test -d "$@" || mkdir -vp "$@"



# System detection
# ================
@@ -135,26 +156,23 @@ endif
# preparing files
# ===============

ifeq (,$(use_git))
$(warning 'use_git' is set to empty. Use curl to fetch files)
$(dotfiles_dir)/%:
mkdir -vp $(dotfiles_dir)
files_fullpath := $(files:%=$(dotfiles_dir)/%)
fetch_files := $(files:%=fetch-%)
.PHONY: $(fetch_files)

$(fetch_files): fetch-%: $(dotfiles_dir)
curl --url $(dotfiles_url_base)/$* --output $@


ifeq (,$(use_git))
$(files_fullpath): $(dotfiles_dir)/%: fetch-%
$(warning 'use_git' is empty. Use curl to fetch files)
else
$(warning 'use_git' is set to non-empty. Use git to retrieve files)
$(dotfiles_dir)/%: setup-repository
$(warning 'use_git' is not empty. Use git to retrieve files)
$(files_fullpath): setup-repository
test -f "$@"
endif

# Shortcut target for interactive usage
# For example, `make file-emacs.el use_git=` will fetch emacs.el from web with
# curl program.
# NOTE: Is there any way to make all `file-%` targets phony?
file-%: $(dotfiles_dir)/%
test -f "$<"

# Make sure $(dotfiles_dir)/% wont be removed as intermidiate files
.PRECIOUS: $(dotfiles_dir)/%



@@ -187,7 +205,7 @@ setup_utils_path := $(setup_utils:%=$(bindir)/%)

$(setup_utils): %: $(bindir)/%

$(setup_utils_path):
$(setup_utils_path): $(bindir)
$(curl) -L --url "$(util_url)" --output "$@"
chmod +x "$@"

@@ -199,17 +217,6 @@ ack-2.12: util_url := http://beyondgrep.com/ack-2.12-single-file



# create directories
# ------------------

setup_directories := $(localdir) $(vardir) $(bindir)
setup-directory: $(setup_directories)

$(localdir) $(vardir) $(bindir):
mkdir -vp $@



# darwin setup
# ------------

@@ -320,27 +327,43 @@ endif
# Load codes are defined by following SETUP_LOAD: indicator.
# String DOTFILES_DIR in the load codes will be replaced into the value of
# $(dotfiles_dir).
# If append_load is non-empty, the load codes are appended to $(topfile),
# otherwise the code will be just printed out to stdout.
# The load codes are appended to $(topfile).

setup_rcs := setup-rc-vimrc setup-rc-tmux.conf setup-rc-emacs.el
setup-rc: $(setup_rcs)
.PHONY: $(setup_rcs)

setup-rc-vimrc: $(home)/.vimrc
setup-rc-tmux.conf: $(home)/.tmux.conf
setup-rc-emacs.el: $(home)/.emacs.d/init.el

$(home)/.emacs.d/init.el: $(dotfiles_dir)/emacs.el $(home) $(home)/.emacs.d
$(home)/.vimrc: $(dotfiles_dir)/vimrc $(home)
$(home)/.tmux.conf: $(dotfiles_dir)/tmux.conf $(home)

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_marker := ADDED BY 10sr_dotfiles/Makefile

$(home)/.emacs.d/init.el $(home)/.vimrc $(home)/.tmux.conf:
set -x; if ! $(grep) "$(setup_rc_marker)" "$@"; \
then \
(echo '$(line_comment)' $(setup_rc_marker); cat "$<" | $(command_extract_setup_load)) \
| tee -a "$@"; \
fi

$(home)/.emacs.d/init.el: line_comment := ;;
$(home)/.vimrc: line_comment := \"
$(home)/.tmux.conf: line_comment := \#



setup-rc-vimrc: topfile := $(home)/.vimrc
setup-rc-tmux.conf: topfile := $(home)/.tmux.conf
setup-rc-emacs.el: topfile := $(home)/.emacs.d/init.el
# run
# ===

run-emacs: $(home)/.emacs.d/init.el
$(emacs) -q --eval "(setq user-emacs-directory \"$(home)/.emacs.d/\")" --load "$<"



@@ -395,8 +418,3 @@ sexp_elisp_syntax_check := \
$(test_syntax_els): test-syntax-%: $(dotfiles_dir)/%
$(emacs) -Q --debug-init --batch \
--eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill



run-emacs:
$(emacs) -nw

+ 35
- 29
emacs.el Zobrazit soubor

@@ -30,6 +30,14 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Some macros for internals

(defun call-after-init (func)
"If `after-init-hook' has been run, call FUNC immediately.
Otherwize hook it."
(if after-init-time
(funcall func)
(add-hook 'after-init-hook
func)))

(defmacro defvar-set (symbol value &optional docstring)
"Define SYMBOL as a variable and set to VALUE.

@@ -277,12 +285,11 @@ IF OK-IF-ALREADY-EXISTS is true force download."
(let ((kill-emacs-hook nil))
(kill-emacs)))

(add-hook 'after-init-hook
(lambda ()
(message "%s %s" invocation-name emacs-version)
(message "%s was taken to initialize emacs." (emacs-init-time))
(switch-to-buffer "*Messages*")
))
(call-after-init
(lambda ()
(message "%s %s" invocation-name emacs-version)
(message "%s was taken to initialize emacs." (emacs-init-time))
(switch-to-buffer "*Messages*")))

(cd ".") ; when using windows use / instead of \ in `default-directory'

@@ -303,9 +310,10 @@ IF OK-IF-ALREADY-EXISTS is true force download."
;; (comint-show-maximum-output)

;; kill scratch
(add-hook 'after-init-hook
(lambda ()
(kill-buffer "*scratch*")))
(call-after-init (lambda ()
(let ((buf (get-buffer "*scratch*")))
(when buf
(kill-buffer buf)))))

;; modifier keys
;; (setq mac-option-modifier 'control)
@@ -448,11 +456,9 @@ IF OK-IF-ALREADY-EXISTS is true force download."

;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title
;; display date
(add-hook 'after-init-hook
(lambda ()
(when display-time-mode
(display-time-update))
))
(call-after-init (lambda ()
(when display-time-mode
(display-time-update))))

(when (safe-require-or-eval 'time)
(setq display-time-interval 29)
@@ -825,7 +831,7 @@ IF OK-IF-ALREADY-EXISTS is true force download."
;; Load scim-bridge.
(when (safe-require-or-eval 'scim-bridge)
;; Turn on scim-mode automatically after loading .emacs
(add-hook 'after-init-hook 'scim-mode-on)
(call-after-init 'scim-mode-on)
(defvar-set scim-cursor-color "red")
(scim-define-preedit-key ?\^h t)
(scim-define-common-key ?\* nil)
@@ -916,16 +922,16 @@ IF OK-IF-ALREADY-EXISTS is true force download."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; https://github.com/lunaryorn/flycheck
(when (safe-require-or-eval 'flycheck)
(add-hook 'after-init-hook 'global-flycheck-mode))
(call-after-init 'global-flycheck-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; window

(and (fetch-library
"https://raw.github.com/10sr/emacs-lisp/master/window-organizer.el"
t)
(autoload-eval-lazily 'window-organizer)
(define-key ctl-x-map (kbd "w") 'window-organizer))
'(and (fetch-library
"https://raw.github.com/10sr/emacs-lisp/master/window-organizer.el"
t)
(autoload-eval-lazily 'window-organizer)
(define-key ctl-x-map (kbd "w") 'window-organizer))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; server
@@ -1010,13 +1016,13 @@ IF OK-IF-ALREADY-EXISTS is true force download."
(autoload-eval-lazily 'sql '(sql-mode)
(safe-require-or-eval 'sql-indent))

(and (fetch-library "https://raw.github.com/10sr/emacs-lisp/master/gtkbm.el"
t)
(autoload-eval-lazily 'gtkbm)
(global-set-key (kbd "C-x C-d") 'gtkbm))
'(and (fetch-library "https://raw.github.com/10sr/emacs-lisp/master/gtkbm.el"
t)
(autoload-eval-lazily 'gtkbm)
(global-set-key (kbd "C-x C-d") 'gtkbm))

(and (fetch-library
"https://raw.github.com/10sr/emacs-lisp/master/git-command.el"
"https://raw.github.com/10sr/git-command-el/master/git-command.el"
t)
(autoload-eval-lazily 'git-command
nil
@@ -1323,7 +1329,7 @@ IF OK-IF-ALREADY-EXISTS is true force download."
'aggressive))

(defvar-set woman-cache-filename (expand-file-name (concat user-emacs-directory
"woman_cache.el")))
"woman_cache.el")))
(defalias 'man 'woman)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2004,8 +2010,8 @@ Optional prefix ARG says how many lines to unflag; default is one line."
C-x t to toggling emacs-text-mode

"
(shell-command-to-string "uname -a")
))
(shell-command-to-string "uname -a")
))

(defvar eshell-text-mode-map
(let ((map (make-sparse-keymap)))


Načítá se…
Zrušit
Uložit