* Color and Fonts Settings
** highlight current line
-
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
- (global-hl-line-mode)
-
+ ;; (global-hl-line-mode)
+ ;; don't want high light current line in eshell/term mode
+ (add-hook 'prog-mode-hook 'hl-line-mode)
+ (add-hook 'text-mode-hook 'hl-line-mode)
#+END_SRC
** Smart Comments
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(defvar mode-line-cleaner-alist
`((auto-complete-mode . " α")
- (yas/minor-mode . " υ")
(paredit-mode . " π")
(eldoc-mode . "")
(abbrev-mode . "")
(flyspell-mode . "")
(irony-mode . "")
(page-break-lines-mode . "")
+ (yas-minor-mode . "y")
;; Major modes
(lisp-interaction-mode . "λ")
(hi-lock-mode . "")
#+END_SRC
** Multi-term
+define =multi-term= mapping to disable some mapping which is used globally.
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package multi-term
:ensure t)
+
+ (defun sd/term-mode-mapping ()
+ (mapcar (lambda (map)
+ (define-key map (kbd "C-o") nil)
+ (define-key map (kbd "C-g") nil))
+ (list term-mode-map
+ term-raw-map)))
+
+ (with-eval-after-load 'multi-term
+ (sd/term-mode-mapping))
#+END_SRC
** ace-link
:ensure t)
#+END_SRC
+** Local Variable hooks
+[[https://www.emacswiki.org/emacs/LocalVariables][LocalVariables]], use =hack-local-variables-hook=, run a hook to set local variable in mode hook
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ ;; make Emacs run a new "local variables hook" for each major mode
+ (add-hook 'hack-local-variables-hook 'run-local-vars-mode-hook)
+
+ (defun run-local-vars-mode-hook ()
+ "Run a hook for the major-mode after the local variables have been processed."
+ (run-hooks (intern (concat (symbol-name major-mode) "-local-vars-hook"))))
+
+ ;; (add-hook 'c++-mode-local-vars-hook #'sd/c++-mode-local-vars)
+#+END_SRC
+
+** Table
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (add-hook 'text-mode-hook 'table-recognize)
+#+END_SRC
+
* Dired
** Dired bindings
=C-o= is defined as a global key for window operation, here unset it in dired mode
#+END_SRC
** C & C++
+C/C++ ide tools
+1. completion (file name, function name, variable name)
+2. template yasnippet (keywords, if, function)
+3. tags jump
*** c/c++ style
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(setq c-default-style "stroustrup"
c-basic-offset 4)
-#+END_SRC
-*** flycheck
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (use-package flycheck
- :ensure t)
+ ;; "C-M-j" is my global binding for avy goto line below
+ ;; disable it in c mode
+ (mapcar '(lambda (map)
+ (define-key map (kbd "C-M-j") nil))
+ (list c-mode-map
+ c++-mode-map
+ objc-mode-map))
#+END_SRC
*** irony
'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
'irony-completion-at-point-async))
+
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
+
+ (add-hook 'c++-mode-local-vars-hook #'sd/c++-mode-local-vars)
+
+ ;; add C++ completions, because by default c++ file can not complete
+ ;; c++ std functions, another method is create .dir-local.el file, for p
+ ;; for project see irony
+ (defun sd/c++-mode-local-vars ()
+ (setq irony--compile-options
+ '("-std=c++11"
+ "-stdlib=libc++"
+ "-I/usr/include/c++/4.2.1")))
#+END_SRC
irony-company
:ensure t)
(use-package company-c-headers
- :ensure t)
+ :ensure t
+ :config
+ (add-to-list 'company-c-headers-path-system "/usr/include/c++/4.2.1/"))
(with-eval-after-load 'company
- (add-to-list 'company-backends '(company-irony company-c-headers)))
+ (add-to-list 'company-backends 'company-irony)
+ (add-to-list 'company-backends 'company-c-headers))
(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
+
+*** yasnippet
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (use-package yasnippet
+ :ensure t
+ :defer t
+ :init
+ (add-hook 'prog-mode-hook #'yas-minor-mode)
+ :config
+ (yas-reload-all))
+#+END_SRC
+
*** gtags
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package ggtags
- :ensure t)
+ :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 ()
#+END_SRC
-*** yasnippet
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (use-package yasnippet
- :ensure t
- :defer t
- ;; :config
- )
- ;; (yas-reload-all)
- ;; (add-hook 'prog-mode-hook #'yas-minor-mode)
- ;; (yas-global-mode 1)
-
-#+END_SRC
-
-*** semantic
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
-#+END_SRC
-
*** google C style
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
(use-package google-c-style
(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 "r") #'recompile))
+
+ (global-set-key (kbd "s-r") 'compile)
#+END_SRC
* Auto-Insert
;; other special buffers
("d" sd/project-or-dired-jump nil :exit t)
("b" ibuffer nil :exit t)
+ ("t" multi-term nil :exit t)
("e" sd/toggle-project-eshell nil :exit t)
("m" bookmark-jump-other-window nil :exit t)
("M" bookmark-set nil :exit t)