Skip to content

Instantly share code, notes, and snippets.

@Sd-Invol
Created May 23, 2019 10:27
Show Gist options
  • Save Sd-Invol/17493120c2e43d1de76eceb32f78a09b to your computer and use it in GitHub Desktop.
Save Sd-Invol/17493120c2e43d1de76eceb32f78a09b to your computer and use it in GitHub Desktop.
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(ansi-color-names-vector
["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
'(column-number-mode t)
'(custom-enabled-themes (quote (deeper-blue)))
'(delete-selection-mode t)
'(package-selected-packages (quote (flycheck irony-eldoc irony auto-complete ##)))
'(show-paren-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Consolas" :foundry "Mircosoft" :slant normal :weight normal :height 152 :width normal)))))
;;;;;;;;;;;;;;;;;;;;;;;;;
;; modify $PATH to adapt gcc version
(setenv "PATH"
(concat
(getenv "PATH")
":""/usr/local/bin"))
;; We don't want to type yes and no all the time so, do y and n
(defalias 'yes-or-no-p 'y-or-n-p)
;; about auto-complete mode
(require 'auto-complete)
(ac-config-default)
;; static warning
;; (require 'flycheck)
;; (add-hook 'c++-mode-hook
;; (lambda () (setq flycheck-gcc-language-standard "c++11")))
;; (add-hook 'c-mode-hook 'flycheck-mode)
;; (add-hook 'c++-mode-hook 'flycheck-mode)
;; irony-mode for auto complete
;; (require 'irony)
;; (add-hook 'c++-mode-hook 'irony-mode)
;; (add-hook 'c-mode-hook 'irony-mode)
;; (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(defconst my-cpp-style
'((c-comment-only-line-offset . 0)
(c-offsets-alist . ((innamespace . 0) ;;; Don't indent for namespace enclusures
(inextern-lang . 0) ;;; As for namespaces, don't indent for extern "C" {
(inlambda . 0) ;;; no extra indent for lambda
(substatement-open . 0) ;;; Don't indent opening '{' from control statement
(statement-block-intro . +) ;;; Indent code in "{' one offset
(label . 0) ;;; Don;'t indent labels to show them off
(statement-cont . +) ;;; Indent statement continuation lines one offset
(case-label . +) ;;; Indent case labels one offset from opening switch
(arglist-intro . +) ;;; Indent first line of argument list one offset
(arglist-cont . 0) ;;; Indent arguments after blah(\n one offset
(arglist-cont-nonempty . +) ;;; Indent args after blah( int arg1 on next line one offset
(arglist-close . +) ;;; Align the closing ')' with arguments
))
(c-label-minimum-indentation 0) ;;; Was in "stroustrup" stype
)
"My default C++ coding style")
(add-hook 'c++-mode-hook 'my-cpp-mode)
(defun my-cpp-mode()
(define-key c++-mode-map [return] 'newline-and-indent)
(define-key c++-mode-map [f7] 'compile)
(c-add-style "my-cpp-style" my-cpp-style t) ;;; 't' == make default
(interactive)
(c-set-style "K&R")
;; (c-toggle-auto-state)
(c-toggle-hungry-state)
;; (c-toggle-auto-newline)
(setq c-basic-offset 4)
(imenu-add-menubar-index)
(which-function-mode)
(show-paren-mode t)
(setq show-paren-style 'parentheses))
(add-hook 'before-save-hook (lambda () (whitespace-cleanup)))
(setq-default indent-tabs-mode nil)
(setq auto-save-default nil)
(setq make-backup-files nil)
(global-linum-mode t)
(setq line-number-mode t)
(setq column-number-mode t)
(setq mac-option-modifier 'super)
(setq mac-command-modifier 'meta)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment