Skip to content

Instantly share code, notes, and snippets.

@bruinfish
Created June 8, 2015 19:02
Show Gist options
  • Save bruinfish/ed6e3a91ec1a58a37388 to your computer and use it in GitHub Desktop.
Save bruinfish/ed6e3a91ec1a58a37388 to your computer and use it in GitHub Desktop.
.emacs-old
(global-hl-line-mode 1)
(transient-mark-mode 1)
(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.
'(gud-gdb-command-name "gdb --annotate=1")
'(large-file-warning-threshold nil)
'(safe-local-variable-values (quote ((py-indent-offset . 4)))))
(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.
)
(global-set-key "\M-g" 'goto-line)
;; Line commenting
;; Original idea from
;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html
(defun comment-dwim-line (&optional arg)
"Replacement for the comment-dwim command.
If no region is selected and current line is not blank, then comment current line.
Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line."
(interactive "*P")
(comment-normalize-vars)
(if (not (region-active-p))
(comment-or-uncomment-region (line-beginning-position) (line-end-position))
(comment-dwim arg)
)
(setq deactivate-mark nil))
(global-set-key "\M-;" 'comment-dwim-line) ;; compatible to terminal emacs
(global-set-key (kbd "A-/") 'comment-dwim-line) ;; for aquamacs
;; ;; (require 'smarty-mode)
;; (add-hook 'c-mode-common-hook
;; (lambda()
;; (local-set-key (kbd "C-c o") 'eassist-switch-h-cpp)
;; (local-set-key (kbd "M-o") 'eassist-switch-h-cpp)
;; (local-set-key (kbd "M-m") 'eassist-list-methods)))
(load-file "~/.emacs.d/cedet/common/cedet.el")
;; Enable EDE (Project Management) features
(global-ede-mode 1)
;; * This enables the database and idle reparse engines
(semantic-load-enable-minimum-features)
;; * This enables some tools useful for coding, such as summary mode,
;; imenu support, and the semantic navigator
(semantic-load-enable-code-helpers)
;; * This enables even more coding tools such as intellisense mode,
;; decoration mode, and stickyfunc mode (plus regular code helpers)
;; (semantic-load-enable-gaudy-code-helpers)
;; Enable SRecode (Template management) minor-mode.
;; (global-srecode-minor-mode 1)
;; Enable Semantic
;; (semantic-mode 1)
;; Add macports includes
(semantic-add-system-include "/opt/macports/include" 'c++-mode)
(semantic-add-system-include "/opt/macports/include" 'c-mode)
(add-hook 'c-mode-common-hook
(lambda()
(local-set-key (kbd "C-c o") 'eassist-switch-h-cpp)
(local-set-key (kbd "M-o") 'eassist-switch-h-cpp)
(local-set-key (kbd "M-m") 'eassist-list-methods)
(flyspell-prog-mode)
(c-set-style "gnu")
(local-set-key (kbd "RET") 'newline-and-indent)
(setq comment-start "//" comment-end "")
(setq-default indent-tabs-mode nil)
(whitespace-mode)
)
)
;; Hacking GNU c/c++ style
;; After trying my ass off, this is the only solution to add
;; "innamespace -" after local variables (style) is applied to a file
(c-add-style "gnu"
'(
(c-basic-offset . 2)
(c-comment-only-line-offset 0 . 0)
(c-hanging-braces-alist
(substatement-open before after)
(arglist-cont-nonempty))
(c-offsets-alist
(innamespace . -)
(statement-block-intro . +)
(knr-argdecl-intro . 5)
(substatement-open . +)
(substatement-label . 0)
(label . 0)
(statement-case-open . +)
(statement-cont . +)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
(inline-open . 0)
(brace-list-open . +)
(topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont))
(c-special-indent-hook . c-gnu-impose-minimum)
(c-block-comment-prefix . "")
)
)
;; remove trailing whitespace
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; tabs
(setq-default indent-tabs-mode nil)
;; highlight lines > 100 columns & tabs
(require 'whitespace)
(setq whitespace-style '(face empty tabs lines-tail trailing))
(setq whitespace-line-column 100)
;; (global-whitespace-mode t)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is your old M-x.
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t)
;; (setq ido-everywhere t)
;; (ido-mode t)
(require 'ido-vertical-mode)
(ido-vertical-mode t)
;; dash-at-point configuration
(autoload 'dash-at-point "dash-at-point"
"Search the word at point with Dash." t nil)
(global-set-key "\C-cd" 'dash-at-point)
;; set javascript indent
(setq js-indent-level 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment