Skip to content

Instantly share code, notes, and snippets.

@finetjul
Created February 19, 2013 14:45
Show Gist options
  • Save finetjul/4986514 to your computer and use it in GitHub Desktop.
Save finetjul/4986514 to your computer and use it in GitHub Desktop.
(modify-frame-parameters nil '((wait-for-wm . nil)))
(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.
'(column-number-mode 1)
'(gdb-max-frames 200)
'(indent-tabs-mode nil)
'(inhibit-default-init t)
'(inhibit-startup-buffer-menu t)
'(inhibit-startup-screen t)
'(standard-indent 2)
'(tab-stop-list (quote (2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52)))
'(tab-width 2))
(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 (:inherit nil :stipple nil :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 109 :width normal :foundry "unknown" :family "Anonymous Pro")))))
;; for easy install
;; sudo apt-get install emacs-goodies-el
;; sudo apt-get install cscope
;;(custom-set-faces
;;'(default ((t (:stipple nil :background ((image :type jpeg :file "~/image.png") :origin display) :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 101 :width normal :family "misc-fixed")))))
(load-file "~/.emacs.d/sourcepair.el")
(load-file "~/.emacs.d/autopair.el")
;; Wanna do changes and reload the changes without reloading emacs:
;; M-x load-file RET ~/.emacs
;; Show column number
(setq column-number-mode 1)
;; Change the window title to have only the file name
(setq frame-title-format '(buffer-file-name "%b (%f)" "%b" ))
;; Pimp emacs: Color theme (to test the themes, run: M-x color-theme-select )
;;(require 'color-theme)
;;(setq color-theme-is-global t)
;;(color-theme-montz)
;; show trailing withespace
(custom-set-variables '(show-trailing-whitespace t))
;; This binds word completions to Shift-Tab
(global-set-key [S-iso-lefttab] 'dabbrev-completion)
;; and Ctrl+Space
;;(global-unset-key [?\C-\040])
;;(global-set-key [?\C-\040] 'dabbrev-completion)
;;(add-to-list 'load-path "~/emacs.d")
(require 'autopair) ;; takes care of the brackets and parenthesis
(autopair-global-mode 1) ;; enable autopair in all buffer
(setq autopair-blink t)
(setq cua-enable-cua-keys nil)
(cua-mode t)
;; switch window
(global-unset-key "\C-z")
(define-key global-map "\C-xz" 'sourcepair-load)
;; cycle through buffers with Ctrl-Tab (like Firefox)
(global-set-key (kbd "<C-tab>") 'other-window)
(defun previous-window () (interactive) (other-window -1))
(global-set-key (kbd "<C-S-iso-lefttab>") 'previous-window)
;; Compile binded to the f5 key
(global-set-key [f5] 'recompile)
(global-set-key [(shift f5)] 'compile)
;; Run gdb
(global-set-key [f7] 'gdb)
(global-set-key [f8] 'gdb-many-windows)
(global-set-key [(shift f8)] 'delete-other-windows)
(global-set-key [pause] 'toggle-current-window-dedication)
;; Menu for the kill-ring : C-c y
(global-set-key "\C-cy" '(lambda ()
(interactive)
(popup-menu 'yank-menu)))
;; in the following base style is gnu
(require 'cc-mode)
;;(c-set-offset 'statement-block-intro 0)
;; namespaces don't indent the content
;;(c-set-offset 'innamespace 0)
;; when a parenthesis is open, if a new line the first argument is indented (does not start after the open parenthesis)
;;(c-set-offset 'arglist-intro 'c-basic-offset)
;; in the typedef enum contents
;;(c-set-offset 'brace-list-intro 0)
;; Make .h, .H, .txx and .tpp files default to C++ mode rather than C mode.
(setq auto-mode-alist
(append
'(("\\.H$" . c++-mode)
("\\.h$" . c++-mode)
("\\.txx$" . c++-mode)
("\\.tpp$" . c++-mode))
auto-mode-alist))
;; Set a window dedicated to a buffer
(defun toggle-current-window-dedication ()
(interactive)
(let* ((window (selected-window))
(dedicated (window-dedicated-p window)))
(set-window-dedicated-p window (not dedicated))
(message "Window %sdedicated to %s"
(if dedicated "no longer " "")
(buffer-name))))
;; Winner Mode
;; use c-c left and c-c right to "undo" window layout
(when (fboundp 'winner-mode)
(winner-mode 1))
;; COMPILATION
;; Note: use C-x ` to get to the next error.
;; Scroll the compilation output to the first error
(setq compilation-scroll-output 'first-error)
(setq compile-command "auto_make_all -j8 -Wall ")
;; Close the compilation frame when finish on success
(setq compilation-finish-functions 'compile-autoclose)
(defun compile-autoclose (buffer string)
(cond ((string-match "finished" string)
(bury-buffer "*compilation*")
(winner-undo)
(message "Build successful."))
(t
(message "Compilation exited abnormally: %s" string))))
;; ETAGS
;; Run etags (as a script?) in your work directory.
;; Note: etags from "Exuberant ctags" is better than etags from emacs.
;; cd ~/work
;; ETAGS=etags # Exuberant ctags
;; if [ -e TAGS ]; then
;; rm TAGS;
;; fi
;;
;; find . ! -path "*Slicer3*" ! -path "*-Debug*" ! -path "*-Release*" ! -path "*-build*" -name '*.cpp' -print0 \
;; | xargs --null $ETAGS --append --extra=+q --fields=+fksaiS --c++-kinds=+px
;; find . ! -path "*Slicer3*" ! -path "*-Debug*" ! -path "*-Release*" ! -path "*-build*" -name '*.cxx' -print0 \
;; | xargs --null $ETAGS --append --extra=+q --fields=+fksaiS --c++-kinds=+px
;; find . ! -path "*Slicer3*" ! -path "*-Debug*" ! -path "*-Release*" ! -path "*-build*" -name '*.txx' -print0 \
;; | xargs --null $ETAGS --append --extra=+q --fields=+fksaiS --c++-kinds=+px
;; find . ! -path "*Slicer3*" ! -path "*-Debug*" ! -path "*-Release*" ! -path "*-build*" -name '*.c' -print0 \
;; | xargs --null $ETAGS --append --extra=+q --fields=+fksaiS --c++-kinds=+px
;; find . ! -path "*Slicer3*" ! -path "*-Debug*" ! -path "*-Release*" ! -path "*-build*" -name '*.h' -print0 \
;; | xargs --null $ETAGS --append --extra=+q --fields=+fksaiS --c++-kinds=+px
;; In emacs: M-. on a symbol, M-C-i for auto completion
;; Xcscope can return all the expression that call one function ( C-c s s )
;;(require 'xcscope)
;; GDB
;; nothing required for gdb, just M-x gdb
;; if you want all the cool windows: M-x gdb-many-windows
;; SVN (can do cvs too)
;; C-x v g (annotate)
;; C-x v = (diff)
;; C-x v ~ (diff between revisions)
;; M-x svn-status
;; CMake highlighting and indentation for CMakeLists.txt and
;; *.cmake source files.
;;(setq load-path (cons (expand-file-name ".emacs.d/cmake-mode") load-path))
;;(require 'cmake-mode)
(load-file "~/.emacs.d/cmake-mode.el")
(setq auto-mode-alist
(append '(("CMakeLists\\.txt\\'" . cmake-mode)
("\\.cmake\\'" . cmake-mode))
auto-mode-alist))
;; KWStyle
(defun c-set-indent-vtk ()
(interactive)
(setq c-basic-offset 2)
(setq c-comment-only-line-offset 0)
(setq c-indent-comments-syntactically-p t)
(setq c-electric-pound-behavior '(alignleft))
(setq indent-tabs-mode nil)
(c-set-offset 'case-label 0)
(c-set-offset 'label 0)
(c-set-offset 'topmost-intro-cont 0)
(c-set-offset 'block-open '+)
(c-set-offset 'block-close 0)
(c-set-offset 'substatement '+)
(c-set-offset 'substatement-open '+)
(c-set-offset 'statement-block-intro 0)
(c-set-offset 'access-label '-)
(c-set-offset 'string 'c-lineup-dont-change)
(c-set-offset 'c 'c-lineup-C-comments)
(c-set-offset 'defun-open 0)
(c-set-offset 'defun-close 0)
(c-set-offset 'defun-block-intro '+)
(c-set-offset 'class-open 0)
(c-set-offset 'class-close 0)
(c-set-offset 'inline-open 0)
(c-set-offset 'inline-close 0)
(c-set-offset 'func-decl-cont '+)
(c-set-offset 'knr-argdecl-intro 5)
(c-set-offset 'knr-argdecl 0)
(c-set-offset 'topmost-intro 0)
(c-set-offset 'member-init-intro '+)
(c-set-offset 'member-init-cont 0)
(c-set-offset 'inher-intro '+)
(c-set-offset 'inher-cont 'c-lineup-multi-inher)
(c-set-offset 'brace-list-open 0)
(c-set-offset 'brace-list-close 0)
(c-set-offset 'brace-list-intro '+)
(c-set-offset 'brace-list-entry 0)
(c-set-offset 'brace-entry-open 0)
(c-set-offset 'statement 0)
(c-set-offset 'statement-cont '+)
(c-set-offset 'statement-case-intro '+)
(c-set-offset 'statement-case-open '+)
(c-set-offset 'do-while-closure 0)
(c-set-offset 'else-clause 0)
(c-set-offset 'catch-clause 0)
(c-set-offset 'comment-intro 'c-lineup-comment)
;;(c-set-offset 'arglist-intro 'c-lineup-arglist-intro-after-paren)
;;(c-set-offset 'arglist-intro '+)
;;(c-set-offset 'arglist-cont '(c-lineup-arglist-operators 0))
;;(c-set-offset 'arglist-cont-nonempty '(c-lineup-arglist-operators c-lineup-arglist))
;;(c-set-offset 'arglist-close 'c-lineup-arglist)
;; new
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-cont 'c-lineup-arglist-operators)
(c-set-offset 'arglist-close 'c-lineup-arglist-operators)
(c-set-offset 'stream-op 'c-lineup-streamop)
(c-set-offset 'inclass '+)
(c-set-offset 'cpp-macro -1000)
(c-set-offset 'cpp-macro-cont 'c-lineup-dont-change)
(c-set-offset 'friend 0)
(c-set-offset 'objc-method-intro -1000)
(c-set-offset 'objc-method-args-cont 'c-lineup-ObjC-method-args)
(c-set-offset 'objc-method-call-cont 'c-lineup-ObjC-method-call)
(c-set-offset 'extern-lang-open 0)
(c-set-offset 'extern-lang-close 0)
(c-set-offset 'inextern-lang '+)
(c-set-offset 'namespace-open 0)
(c-set-offset 'namespace-close 0)
;; (c-set-offset 'innamespace '+)
(c-set-offset 'innamespace 0)
(c-set-offset 'template-args-cont '+)
(c-set-offset 'inlambda 'c-lineup-inexpr-block)
(c-set-offset 'lambda-intro-cont '+)
(c-set-offset 'inexpr-statement 0)
(c-set-offset 'inexpr-class '+)
(message "KWStyle indentation"))
(add-hook 'c-mode-common-hook 'c-set-indent-vtk)
(put 'scroll-left 'disabled nil)
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(require 'flymake)
;; flymake
(defun my-flymake-show-next-error()
(interactive)
(flymake-goto-next-error)
(flymake-display-err-menu-for-current-line)
)
;;
;; Setting some C / C++ defaults
;;
(add-hook 'c-mode-common-hook
(function (lambda ()
;; more stuff here
(flymake-mode t)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment