+ ;; (use-package company-irony
+ ;; :ensure t)
+
+ ;; (use-package flycheck-irony
+ ;; :ensure t)
+
+ ;; (use-package company-c-headers
+ ;; :ensure t
+ ;; :config
+ ;; (add-to-list 'company-c-headers-path-system "/usr/include/c++/4.2.1/")
+ ;; (add-to-list 'company-c-headers-path-system "/usr/local/include/"))
+
+ ;; (with-eval-after-load 'company
+ ;; (add-to-list 'company-backends 'company-irony)
+ ;; (add-to-list 'company-backends 'company-c-headers))
+
+ ;; (with-eval-after-load 'company
+ ;; (push '(company-irony :with company-yasnippet) company-backends)
+ ;; (push '(company-c-headers :with company-yasnippet) company-backends))
+
+ ;; (with-eval-after-load 'flycheck
+ ;; (add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
+#+END_SRC
+
+*** flycheck
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package flycheck
+ :ensure t)
+#+END_SRC
+
+*** gtags
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package ggtags
+ :ensure t
+ :config
+ (define-key ggtags-mode-map (kbd "M-g d") 'ggtags-find-definition)
+ (define-key ggtags-mode-map (kbd "M-g r") 'ggtags-find-reference)
+ (define-key ggtags-mode-map (kbd "M-g r") 'ggtags-find-reference)
+ (define-key ggtags-mode-map (kbd "C-c g s") 'ggtags-find-other-symbol)
+ (define-key ggtags-mode-map (kbd "C-c g h") 'ggtags-view-tag-history)
+ (define-key ggtags-mode-map (kbd "C-c g r") 'ggtags-find-reference)
+ (define-key ggtags-mode-map (kbd "C-c g f") 'ggtags-find-file)
+ (define-key ggtags-mode-map (kbd "C-c g c") 'ggtags-create-tags)
+ (define-key ggtags-mode-map (kbd "C-c g u") 'ggtags-update-tags))
+
+ (add-hook 'c-mode-common-hook
+ (lambda ()
+ (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
+ (ggtags-mode 1))))
+
+ (defun sd/ggtags-find-definition ()
+ "Find the definition with current name completing."
+ (interactive)
+ (setq current-prefix-arg '(4))
+ (call-interactively 'ggtags-find-definition))
+
+ (defun sd/ggtags-find-symbol ()
+ "Find symbol"
+ (interactive)
+ (setq current-prefix-arg '(4))
+ (call-interactively 'ggtags-find-other-symbol))
+
+ (require 'cc-mode)
+ (require 'semantic)
+ (setq semanticdb-default-save-directory (concat MY-EMACS-TMP "/semantic/"))
+ (unless (file-exists-p semanticdb-default-save-directory)
+ (make-directory semanticdb-default-save-directory))
+
+ (global-semanticdb-minor-mode 1)
+ (global-semantic-idle-scheduler-mode 1)
+
+ (semantic-mode 1)
+#+END_SRC
+
+*** google C style
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ ;; (use-package google-c-style
+ ;; :ensure t
+ ;; :config
+ ;; (add-hook 'c-mode-hook 'google-set-c-style)
+ ;; (add-hook 'c++-mode-hook 'google-set-c-style))
+#+END_SRC
+
+*** Compile and Run the C file
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (defun my-cpp-hook ()
+ (let* ((current-file-name)
+ (out-file-name))
+ (when buffer-file-name
+ (setq current-file-name (shell-quote-argument buffer-file-name))
+ (setq out-file-name (shell-quote-argument (concat (file-name-sans-extension buffer-file-name) ".out"))))
+ (setq-local compilation-read-command t)
+ (set (make-local-variable 'compile-command)
+ (concat "g++ -Wall -std=c++11 "
+ current-file-name
+ " -o "
+ out-file-name
+ " && "
+ out-file-name
+ ))
+ (local-set-key (kbd "s-r") 'compile)))
+
+ (add-hook 'c-mode-hook 'my-cpp-hook)
+ (add-hook 'c++-mode-hook 'my-cpp-hook)
+#+END_SRC
+
+** Lua
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package lua-mode
+ :ensure t)
+#+END_SRC
+
+** Scheme
+Install =guile=, =guile= is an implementation of =Scheme= programming language.
+#+BEGIN_SRC sh
+ brew install guile
+#+END_SRC
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (setq geiser-scheme-implementation 'guile)
+#+END_SRC
+
+#+BEGIN_SRC scheme
+ (define a "3")
+ a
+#+END_SRC
+
+#+RESULTS:
+: 3
+
+** Racket
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package racket-mode
+ :ensure t
+ :config
+ (define-key racket-mode-map (kbd "s-r") 'racket-run)
+ (add-to-list 'racket-mode-hook (lambda () (lispy-mode 1))))
+
+ ;; set racket path
+ (setenv "PATH" (concat (getenv "PATH")
+ ":" "/Applications/Racket v6.10.1/bin"))
+ (setenv "MANPATH" (concat (getenv "MANPATH")
+ ":" "/Applications/Racket v6.10.1/man"))
+ (setq exec-path (append exec-path '("/Applications/Racket v6.10.1/bin")))
+
+ (add-to-list 'auto-mode-alist '("\\.rkt\\'" . racket-mode))
+#+END_SRC
+* Compile
+Set the environments vairables in compilation mode
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package compile
+ :commands compile
+ :config
+ (setq compilation-environment (cons "LC_ALL=C" compilation-environment))
+ (setq compilation-auto-jump-to-first-error t)
+ (setq compilation-auto-jump-to-next t)
+ (setq compilation-scroll-output 'first-error)
+ ;; this will save all the modified buffers before compile
+ (setq compilation-ask-about-save nil)
+ (setq compilation-window-height (/ (window-total-height) 3)))
+
+ ;; super-r to compile
+ (with-eval-after-load "compile"
+ (define-key compilation-mode-map (kbd "C-o") nil)
+ (define-key compilation-mode-map (kbd "n") 'compilation-next-error)
+ (define-key compilation-mode-map (kbd "p") 'compilation-previous-error)
+ (define-key compilation-mode-map (kbd "q") (lambda () (interactive) (quit-window t)))
+ (define-key compilation-mode-map (kbd "r") #'recompile))
+
+ ;; here note dynamic binding the value of vv, otherwise it will resport error when run the hook.
+ ;; https://emacs.stackexchange.com/questions/10394/scope-in-lambda
+ (dolist (vv '(
+ (cperl-mode-hook . "perl")
+ (lua-mode-hook . "lua")
+ (python-mode-hook . "python")
+ (shell-mode-hook . "sh")))
+ (add-hook (car vv) `(lambda ()
+ (unless (or (file-exists-p "makefile")
+ (file-exists-p "Makefile"))
+ (set (make-local-variable 'compile-command)
+ (concat (cdr ',vv)
+ " "
+ (if buffer-file-name
+ (shell-quote-argument buffer-file-name))))))))
+
+ (global-set-key (kbd "s-r") 'compile)
+#+END_SRC
+
+* Auto-Insert
+** Enable auto-insert mode
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (auto-insert-mode t)
+ (setq auto-insert-query nil)