emacs/.emacs
Adam Goldsmith 31fb2921da split packages into core and extra
both are used to clean up, so none are removed, but only core is sync'd
explicitly, so extra packages are not installed
2015-06-28 09:03:10 -04:00

147 lines
4.2 KiB
Plaintext

;; 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)
(show-paren-mode 1)
;; Keybinds
(global-set-key (kbd "C-z") `recompile)
(global-set-key (kbd "C-S-z") `compile)
;; 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")))
;; 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-core
'(el-get
smart-mode-line
avy
smex
ace-window
company
tramp
hideif
magit
undo-tree
hydra
multiple-cursors))
(setq my-packages-extra
'(lua-mode
pkgbuild-mode
arduino-mode
gnuplot-mode
csharp-mode
markdown-mode
todotxt-mode
php-mode
scad-mode
smarttabs
jedi-core
company-jedi))
;;auctex))
(el-get-cleanup (append my-packages-core my-packages-extra))
(el-get 'sync my-packages-core)
(el-get 'sync)
;;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)))
(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.
)