2015-04-25 21:51:54 -04:00
|
|
|
;; indentation
|
|
|
|
(setq c-default-style "linux"
|
|
|
|
c-basic-offset 4
|
|
|
|
sgml-basic-offset 4)
|
|
|
|
(c-set-offset `inline-open 0)
|
|
|
|
(setq-default tab-width 4)
|
|
|
|
(add-hook 'sh-mode-hook (lambda () (setq tab-width 4)))
|
|
|
|
|
|
|
|
;; various options
|
|
|
|
(setq compilation-scroll-output 1
|
|
|
|
read-file-name-completion-ignore-case t
|
|
|
|
inhibit-startup-screen t
|
|
|
|
vc-follow-symlinks t)
|
2015-05-03 09:45:48 -04:00
|
|
|
(load-theme 'fred t)
|
|
|
|
(savehist-mode 1)
|
2015-06-27 15:19:40 -04:00
|
|
|
(show-paren-mode 1)
|
2015-06-28 23:59:30 -04:00
|
|
|
(when (display-graphic-p)
|
|
|
|
(tool-bar-mode -1))
|
2015-05-03 09:45:48 -04:00
|
|
|
|
|
|
|
;; Keybinds
|
|
|
|
(global-set-key (kbd "C-z") `recompile)
|
|
|
|
(global-set-key (kbd "C-S-z") `compile)
|
2015-04-25 21:51:54 -04:00
|
|
|
|
|
|
|
;; save backups and autosaves in tmp
|
|
|
|
(setq backup-directory-alist
|
|
|
|
`((".*" . ,temporary-file-directory)))
|
|
|
|
(setq auto-save-file-name-transforms
|
|
|
|
`((".*" ,temporary-file-directory t)))
|
|
|
|
|
2015-05-03 09:45:48 -04:00
|
|
|
|
|
|
|
;; use windmove to move point with shift+arrow key
|
|
|
|
(when (fboundp 'windmove-default-keybindings)
|
|
|
|
(windmove-default-keybindings))
|
|
|
|
|
|
|
|
;; define function for inserting today's date
|
|
|
|
(defun insert-date ()
|
|
|
|
(interactive)
|
|
|
|
(insert (format-time-string "%Y.%m.%d")))
|
|
|
|
|
2015-04-25 21:51:54 -04:00
|
|
|
;; load el-get
|
|
|
|
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
|
|
|
|
(unless (require 'el-get nil 'noerror)
|
|
|
|
(with-current-buffer
|
|
|
|
(url-retrieve-synchronously
|
|
|
|
"https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el")
|
|
|
|
(goto-char (point-max))
|
2015-06-29 00:04:26 -04:00
|
|
|
(eval-print-last-sexp))
|
|
|
|
(el-get-elpa-build-local-recipes))
|
2015-04-25 21:51:54 -04:00
|
|
|
|
|
|
|
(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipies")
|
|
|
|
(setq el-get-user-package-directory "~/.emacs.d/el-get-user/init-files")
|
2015-06-28 09:03:03 -04:00
|
|
|
(setq my-packages-core
|
2015-05-03 09:45:48 -04:00
|
|
|
'(el-get
|
|
|
|
smart-mode-line
|
2015-06-05 09:43:43 -04:00
|
|
|
avy
|
2015-06-28 09:01:29 -04:00
|
|
|
smex
|
|
|
|
ace-window
|
2015-05-03 09:45:48 -04:00
|
|
|
company
|
|
|
|
hideif
|
|
|
|
undo-tree
|
2015-06-27 14:19:01 -04:00
|
|
|
hydra
|
2015-06-28 09:03:03 -04:00
|
|
|
multiple-cursors))
|
|
|
|
(setq my-packages-extra
|
2015-07-27 22:21:51 -04:00
|
|
|
'(company-quickhelp
|
|
|
|
pos-tip
|
|
|
|
tramp
|
2015-06-28 20:41:42 -04:00
|
|
|
magit
|
|
|
|
lua-mode
|
2015-05-03 09:45:48 -04:00
|
|
|
pkgbuild-mode
|
|
|
|
arduino-mode
|
|
|
|
gnuplot-mode
|
|
|
|
csharp-mode
|
|
|
|
markdown-mode
|
|
|
|
todotxt-mode
|
|
|
|
php-mode
|
|
|
|
scad-mode
|
2015-07-27 22:21:51 -04:00
|
|
|
qml-mode
|
2015-05-11 23:22:02 -04:00
|
|
|
smarttabs
|
2015-06-28 13:43:58 -04:00
|
|
|
jedi
|
2015-05-11 23:22:02 -04:00
|
|
|
company-jedi))
|
2015-05-03 09:45:48 -04:00
|
|
|
;;auctex))
|
2015-06-28 09:03:03 -04:00
|
|
|
(el-get-cleanup (append my-packages-core my-packages-extra))
|
|
|
|
(el-get 'sync my-packages-core)
|
|
|
|
(el-get 'sync)
|
2015-04-25 21:51:54 -04:00
|
|
|
|
|
|
|
;;allow saving files that need root
|
|
|
|
(defun find-file-as-root(buffer)
|
|
|
|
"use sudo to open a file"
|
|
|
|
(interactive "FFind file as root: ")
|
|
|
|
(find-file (concat "/sudo::" buffer)))
|
|
|
|
(global-set-key (kbd "C-x C-S-f") `find-file-as-root)
|
|
|
|
|
|
|
|
(defadvice save-buffer (around save-buffer-as-root-around activate)
|
|
|
|
"Use sudo to save the current buffer."
|
|
|
|
(interactive "p")
|
|
|
|
(if (and (buffer-file-name) (not (file-writable-p (buffer-file-name))))
|
|
|
|
(let ((buffer-file-name (format "/sudo::%s" buffer-file-name)))
|
|
|
|
ad-do-it)
|
|
|
|
ad-do-it))
|
|
|
|
|
|
|
|
;; c++ headers insertion
|
|
|
|
(defun c++-headers ()
|
|
|
|
(interactive)
|
|
|
|
(if (buffer-file-name)
|
|
|
|
(let*
|
|
|
|
((fName (upcase (file-name-nondirectory (file-name-sans-extension buffer-file-name))))
|
|
|
|
(ifDef (concat "#ifndef " fName "_H" "\n#define " fName "_H" "\n"))
|
|
|
|
(line 3) ;TODO: Make this better
|
|
|
|
)
|
|
|
|
(progn
|
|
|
|
;If less then 5 characters are in the buffer, insert the class definition
|
|
|
|
(if (< (- (point-max) (point-min)) 5 )
|
|
|
|
(progn
|
|
|
|
(insert "\nclass " (capitalize fName) "{\npublic:\n\nprivate:\n\n};\n")
|
|
|
|
(setq line 6)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
;Insert the Header Guard
|
|
|
|
(goto-char (point-min))
|
|
|
|
(insert ifDef)
|
|
|
|
(goto-char (point-max))
|
|
|
|
(insert "\n#endif" " //" fName "_H")
|
|
|
|
(goto-line line))
|
|
|
|
)
|
|
|
|
;else
|
|
|
|
(message (concat "Buffer " (buffer-name) " must have a filename"))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(eval-after-load "cc-mode"
|
|
|
|
'(progn
|
|
|
|
(define-key c-mode-map (kbd "C-c o") 'ff-find-other-file)
|
|
|
|
(define-key c++-mode-map (kbd "C-c o") 'ff-find-other-file)
|
|
|
|
(define-key c-mode-map (kbd "C-c h") 'c++-headers)
|
|
|
|
(define-key c++-mode-map (kbd "C-c h") 'c++-headers)))
|
2015-05-03 09:45:48 -04:00
|
|
|
|
2015-04-25 21:51:54 -04:00
|
|
|
(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.
|
|
|
|
'(safe-local-variable-values
|
|
|
|
(quote
|
|
|
|
((company-clang-arguments "-I/usr/include" "-I/usr/arm-frc-linux-gnueabi/include/")))))
|
|
|
|
(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.
|
|
|
|
)
|