emacs/.emacs

151 lines
4.3 KiB
Plaintext
Raw Normal View History

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)
(load-theme 'fred t)
(savehist-mode 1)
2015-06-27 15:19:40 -04:00
(show-paren-mode 1)
(when (display-graphic-p)
(tool-bar-mode -1))
;; 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)))
;; 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))
(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")
(setq my-packages-core
'(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
company
hideif
undo-tree
2015-06-27 14:19:01 -04:00
hydra
multiple-cursors))
(setq my-packages-extra
'(company-quickhelp
pos-tip
tramp
2015-06-28 20:41:42 -04:00
magit
lua-mode
pkgbuild-mode
arduino-mode
gnuplot-mode
csharp-mode
markdown-mode
todotxt-mode
php-mode
scad-mode
qml-mode
smarttabs
2015-06-28 13:43:58 -04:00
jedi
company-jedi))
;;auctex))
(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-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.
)