Skip to content

Instantly share code, notes, and snippets.

@kornypoet
Created May 6, 2015 17:42
Show Gist options
  • Save kornypoet/505bdf3b352b324d65e5 to your computer and use it in GitHub Desktop.
Save kornypoet/505bdf3b352b324d65e5 to your computer and use it in GitHub Desktop.
;;; General Emacs Settings ;;;
;; Disable startup message
(setq inhibit-startup-message t)
;; Disable menu and tool bar
(menu-bar-mode -1)
(when window-system
(tool-bar-mode -1))
;; Indentation 2 spaces everywhere
(setq-default c-basic-offset 2)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
;; Show column number
(setq column-number-mode t)
;; Font and size for GUI Emacs
(when window-system
(set-frame-font "Inconsolata-20"))
;; Solarized color theme
(when window-system
(add-to-list 'custom-theme-load-path "~/.dotfiles/vendor/emacs-solarized")
(load-theme 'solarized-dark t))
;; Put autosave files (ie #foo#) and backup files (ie foo~) in ~/.emacs.d/.
(custom-set-variables
'(auto-save-file-name-transforms (quote ((".*" "~/.emacs.d/autosaves/\\1" t))))
'(backup-directory-alist (quote ((".*" . "~/.emacs.d/backups/"))))
'(js-indent-level 2))
;; Enable ido mode
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
;; Use CTRL + TAB to switch buffers in GUI mode
(when window-system
(global-set-key (kbd "<C-S-tab>") 'previous-buffer)
(global-set-key (kbd "<C-tab>") 'next-buffer))
;; Key bindings
(global-set-key (kbd "M-;") 'comment-or-uncomment-region)
(global-set-key (kbd "M-g") 'goto-line)
(global-set-key (kbd "M-r") 'query-replace-regexp)
(global-set-key (kbd "C-f") 'next-multiframe-window)
(global-set-key (kbd "C-c C-w") 'whitespace-cleanup)
(global-set-key (kbd "C-c C-t") 'untabify)
;; (global-set-key (kbd "C-x C-g") 'magit-status)
;; Add file types associated with ruby
(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Puppetfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
;; (setq whitespace-style (quote (face spaces trailing tabs newline tab-mark space-mark)))
;; all numbers are Unicode codepoint in decimal. try (insert-char 182 ) to see it
;; (setq whitespace-display-mappings '(
;; (space-mark 32 [183] [46])
;; ))
;; Show tabs as a UTF-8 arrow
;; (standard-display-ascii ?\t "→")
;; Load pig-mode
;; (load-file "~/.dotfiles/pig-mode.el")
;; Load markdown-mode
;;(load-file "~/.dotfiles/markdown-mode.el")
;; Load highlight chars
;; (load-file "~/.dotfiles/highlight-chars.el")
;; (add-hook 'font-lock-mode-hook 'hc-highlight-trailing-whitespace)
;; Load cucumber mode
(add-to-list 'load-path "~/.dotfiles/vendor/cucumber-mode")
(require 'feature-mode)
(add-to-list 'auto-mode-alist '("\\.feature$" . feature-mode))
;; Load yaml mode
(add-to-list 'load-path "~/.dotfiles/vendor/yaml-mode")
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;; Load puppet mode
(load-file "~/.dotfiles/vendor/puppet-mode/puppet-mode.el")
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
;; (add-to-list 'load-path "~/.dotfiles/vendor/puppet-mode")
;; Load scala mode
;; (add-to-list 'load-path "~/.dotfiles/scala-dist/tool-support/src/emacs")
;; (require 'scala-mode-auto)
;; need to fix emacs loading
;; (add-to-list 'load-path "~/.dotfiles")
;; Load magit
;; (add-to-list 'load-path "~/.dotfiles/magit")
;; (require 'magit)
;; Load Go Mode
(add-to-list 'load-path "~/.dotfiles/emacs-modes/go-mode")
(require 'go-mode-autoloads)
;; (setq magit-status-buffer-switch-function 'switch-to-buffer)
(defun djcb-duplicate-line (&optional commentfirst)
"comment line at point; if COMMENTFIRST is non-nil, comment the original"
(interactive)
(beginning-of-line)
(push-mark)
(end-of-line)
(let ((str (buffer-substring (region-beginning) (region-end))))
(when commentfirst
(comment-region (region-beginning) (region-end)))
(insert-string
(concat (if (= 0 (forward-line 1)) "" "\n") str "\n"))
(forward-line -1)))
;; duplicate a line
(global-set-key (kbd "C-c d") 'djcb-duplicate-line)
;; duplicate a line and comment the first
(global-set-key (kbd "C-c ;") (lambda()(interactive)(djcb-duplicate-line t)))
(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.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment