From b2e14c475e7a0beb30b6d7513bc59d79b19194fe Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 27 Apr 2015 23:25:50 -0400 Subject: [PATCH] Clean up and rough :make shortcut --- init.el | 4 ++-- init/init-cc.el | 43 ++++++++++++++++++++++++------------------- init/init-dev.el | 24 ++++++++++++++++++++++-- init/init-lua.el | 4 +--- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/init.el b/init.el index 5bc392d78..a49f33a74 100644 --- a/init.el +++ b/init.el @@ -30,7 +30,7 @@ (defconst *light-theme 'github) ; wtb better light theme... (defconst *fonts `(,(font-spec :family "Terminus (TTF)" :size 12 :antialias nil) - ,(font-spec :family "Ubuntu Mono" :size 16 :antialias t) + ,(font-spec :family "Ubuntu Mono" :size 14 :antialias t) ,(font-spec :family "Inconsolata" :size 22 :antialias t))) (add-to-list 'load-path my-core-dir) @@ -74,7 +74,7 @@ init-java ; the poster child for carpal tunnel syndome init-js ; alert("not java, javascript!") init-lua ; zero-based indices? Zero-based indices. - init-org ; for fearless leader (who is organized) + ;; init-org ; for fearless leader (who is organized) init-php ; making php less painful to work with init-python ; beautiful is better than ugly init-regex ; /^[^\s](meaning)[^\n]*/ diff --git a/init/init-cc.el b/init/init-cc.el index 8266bc3df..337eb0474 100644 --- a/init/init-cc.el +++ b/init/init-cc.el @@ -22,6 +22,7 @@ (associate-mode "\\.mm$" 'objc-mode)) :config (progn + ;; Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq c-basic-offset 4 c-tab-always-indent nil) @@ -39,25 +40,6 @@ (defun my--clang-includes-flags () (mapcar (lambda (item) (concat "-I" item)) my--clang-includes))) - (progn ; C++ - (defun my--setup-c++-mode-flycheck () - (setq flycheck-clang-language-standard "c++11" - flycheck-clang-standard-library "libc++" - flycheck-c/c++-clang-executable "clang++" - flycheck-clang-include-path (my--clang-includes) - )) - (after "flycheck" - (add-hook 'c++-mode-hook 'my--setup-c++-mode-flycheck))) - - (progn ; Obj-C - (add-to-list 'magic-mode-alist - `(,(lambda () - (and (string= (file-name-extension buffer-file-name) "h") - (re-search-forward "@\\" - magic-mode-regexp-match-limit t))) - . objc-mode)) - (after "flycheck" (add-hook! 'objc-mode-hook (use-package flycheck-objc)))) - (after "company" ;; TODO Clang is *really* slow in larger projects, maybe replace it with irony-mode or ycmd? (company--backend-on 'c-mode-hook 'company-c-headers 'company-clang) @@ -89,6 +71,22 @@ (add-hook 'c-mode-hook 'my-c/c++-settings) (add-hook 'c++-mode-hook 'my-c/c++-settings) + (after "flycheck" + (add-hook! 'c++-mode-hook + (setq flycheck-clang-language-standard "c++11" + flycheck-clang-standard-library "libc++" + flycheck-c/c++-clang-executable "clang++" + flycheck-clang-include-path (my--clang-includes)))) + + (progn ; Obj-C + (add-to-list 'magic-mode-alist + `(,(lambda () + (and (string= (file-name-extension buffer-file-name) "h") + (re-search-forward "@\\" + magic-mode-regexp-match-limit t))) + . objc-mode)) + (after "flycheck" (add-hook! 'objc-mode-hook (use-package flycheck-objc)))) + ;; C++11 syntax support (until cc-mode is updated) (require 'font-lock) @@ -156,6 +154,13 @@ (looking-at ".*[(,][ \t]*\\[[^]]*\\][ \t]*[({][^}]*$")))) 0 ; no additional indent ad-do-it))) ; default behavior + + + ;; Tools/defuns ;;;;;;;;;;;;;;;;;;;;;;;; + + (push '("*compilation*" :height 0.5 :position bottom :noselect t) popwin:special-display-config) + + (add-hook! 'c++-mode-hook (setq my-make-command "make %s")) )) diff --git a/init/init-dev.el b/init/init-dev.el index c2ca11dc6..606b14069 100644 --- a/init/init-dev.el +++ b/init/init-dev.el @@ -13,8 +13,8 @@ :init (progn (add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode) - (add-hook 'js2-mode-hook 'rainbow-delimiters-mode) - (add-hook 'scss-mode-hook 'rainbow-delimiters-mode))) + (add-hook 'js2-mode-hook 'rainbow-delimiters-mode) + (add-hook 'scss-mode-hook 'rainbow-delimiters-mode))) ;;; Config modes (use-package yaml-mode @@ -31,6 +31,26 @@ (after "evil" (evil-ex-define-cmd "ref[actor]" 'emr-show-refactor-menu)))) +(bind my-mode-map + "M-b" 'my:build) + +(defvar my-build-command "make %s") +(make-variable-buffer-local 'my-build-command) +(add-hook! 'enh-ruby-mode-hook (setq my-build-command "rake %s")) + +(evil-ex-define-cmd "ma[ke]" 'my:build) +(evil-define-command my:build (arg) + "Call a build command in the current directory. +If ARG is nil this function calls `recompile', otherwise it calls +`compile' passing ARG as build command." + (interactive "") + (let ((makepath (f-traverse-upwards + (lambda (path) + (f-exists? (f-expand "Makefile" path))) + default-directory))) + (if makepath + (compile (format "cd '%s' && %s" makepath (format my-make-command (or arg "")))) + (error "Could not find Makefile")))) (provide 'init-dev) ;;; init-dev.el ends here diff --git a/init/init-lua.el b/init/init-lua.el index a31192b58..a832bbf9d 100644 --- a/init/init-lua.el +++ b/init/init-lua.el @@ -13,9 +13,7 @@ (add-hook 'lua-mode-hook 'enable-tab-width-2) (add-hook! 'lua-mode-hook (setq lua-indent-level tab-width)) - (defun love-run () - (interactive) - (shell-command (format "open -a love.app %s" (my--project-root)))))) + (add-hook! 'love-mode-hook (setq my-build-command (format "open -a love.app %s" (my--project-root)))))) (provide 'init-lua)