emacs/.emacs

143 lines
4.1 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)
(desktop-save-mode 1)
(savehist-mode 1)
(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)))
(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
'(el-get
smart-mode-line
2015-06-05 09:43:43 -04:00
avy
company
tramp
projectile
hideif
magit
undo-tree
2015-06-27 14:19:01 -04:00
ace-window
hydra
lua-mode
pkgbuild-mode
arduino-mode
gnuplot-mode
csharp-mode
markdown-mode
todotxt-mode
php-mode
scad-mode
smarttabs
2015-06-10 23:46:25 -04:00
jedi-core
company-jedi))
;;auctex))
2015-04-25 21:51:54 -04:00
(el-get-cleanup my-packages)
(el-get 'sync my-packages)
;;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.
)