Skip to content

Instantly share code, notes, and snippets.

@brolin
Created March 25, 2016 15:45
Show Gist options
  • Save brolin/2104a30ad52039279018 to your computer and use it in GitHub Desktop.
Save brolin/2104a30ad52039279018 to your computer and use it in GitHub Desktop.
My .emacs file
;; Load CEDET
;;(setq stack-trace-on-error t)
;;(load-file "/usr/share/emacs/site-lisp/cedet/common/cedet.el")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/ecb")
(require 'ecb)
(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.
'(browse-url-temp-dir "~/.emacs.d/vendor/emacs.js/tmp")
'(column-number-mode t)
'(ecb-layout-window-sizes nil)
'(ecb-options-version "2.40")
'(scroll-bar-mode nil)
'(show-paren-mode t)
'(temporary-file-directory "~/.emacs.d/vendor/emacs.js/tmp"))
(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.
)
;; Lua mode
(setq auto-mode-alist (cons '("\.lua$" . lua-mode) auto-mode-alist))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
;; Color theme
;;(require 'color-theme)
;; Zenburn theme
;;(require 'zenburn)
;;(zenburn)
;{{{ Mouse and cursor settings
;
;; Enable mouse scrolling
(mouse-wheel-mode t)
;; Push the mouse out of the way on cursor approach
(mouse-avoidance-mode 'jump)
;; Stop cursor from blinking
(blink-cursor-mode nil)
;; Accelerate the cursor when scrolling
(load "accel" t t)
;;
;; Start scrolling when 2 lines from top/bottom
(setq scroll-margin 2)
;;
;; Fix the scrolling on jumps between windows
(setq scroll-conservatively 5)
;; Cursor in same relative row and column during PgUP/DN
(setq scroll-preserve-screen-position t)
;; Always paste at the cursor
(setq mouse-yank-at-point t)
;; Kill (and paste) text from read-only buffers
(setq kill-read-only-ok 1)
;; Partially integrate the kill-ring and X cut-buffer
;(setq x-select-enable-clipboard t)
;; Copy/paste with accentuation intact
(setq selection-coding-system 'compound-text-with-extensions)
;; Delete selection on a key press
(delete-selection-mode t)
;; Emacs Speaks Statistics
(setq load-path (cons "/usr/share/emacs/site-lisp/ess" load-path))
(require 'ess-site)
;; PHP-mode
(autoload 'php-mode "php-mode.el" "Php mode." t)
(setq auto-mode-alist (append '(("/*.\.php[345]?$" . php-mode)) auto-mode-alist))
;; GEBEN to debug PHP
(autoload 'geben "geben" "DBGp protocol front-end" t)
;; Autopair config
(add-to-list 'load-path "~/.emacs.d/vendor/autopair/")
;; comment if autopair.el is in standard load path
(require 'autopair)
(autopair-global-mode) ;; enable autopair in all buffers
;; Emacs.js config
(defconst +home-dir+ "~")
(defconst +emacs-dir+ (concat +home-dir+ "/.emacs.d/vendor/emacs.js"))
(defconst +emacs-profiles-dir+ (concat +emacs-dir+ "/profiles"))
(defconst +emacs-lib-dir+ (concat +emacs-dir+ "/libs"))
(defconst +emacs-conf-dir+ (concat +emacs-dir+ "/config"))
(defconst +emacs-tmp-dir+ (concat +emacs-dir+ "/tmp"))
;; new projects will be created under this directory
;;(defconst dev-dir (concat home-dir "/dev"))
(defun add-load-path (p)
(add-to-list 'load-path (concat +emacs-dir+ "/" p)))
(defun add-lib-path (p)
(add-to-list 'load-path (concat +emacs-lib-dir+ "/" p)))
(defun load-conf-file (f)
(load-file (concat +emacs-conf-dir+ "/" f ".el")))
(defun load-lib-file (f)
(load-file (concat +emacs-lib-dir+ "/" f)))
(defun load-profile (p)
(load-file (concat +emacs-profiles-dir+ "/" p ".el")))
(defun load-customizations ()
(let ((filename (concat +emacs-dir+ "/custom.el")))
(if (file-readable-p filename)
(load-file filename))))
(add-load-path "")
(add-load-path "lib")
(load-profile "default")
(load-profile "js")
(load-profile "coffee")
(load-customizations)
;;(add-to-list 'command-switch-alist '("clojure" . (lambda (n) (load-profile "clojure"))))
;;(add-to-list 'command-switch-alist '("ruby" . (lambda (n) (load-profile "ruby"))))
;;(add-to-list 'command-switch-alist '("android" . (lambda (n) (load-profile "android"))))
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(autoload 'python-mode "python-mode.el" "Python mode." t)
(setq auto-mode-alist (append '(("/*.\.py$" . python-mode)) auto-mode-alist))
(add-to-list 'load-path "~/.emacs.d/vendor/chuck")
(require 'chuck-mode)
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
;; (web-mode)
;;
;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/web-mode")
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\.html\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.phtml\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.tpl\.php\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.jsp\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.as[cp]x\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.erb\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.mustache\'" . web-mode))
(add-to-list 'auto-mode-alist '("\.djhtml\'" . web-mode))
;;(setq magic-mode-alist '(("<!DOCTYPE html" . web-mode)))
;;configure web-mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html?" . web-mode))
;; multiple-cursors
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(require 'mic-paren)
(paren-activate)
(require 'smex)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;; Smartparens https://github.com/Fuco1/smartparens
(require 'smartparens-config)
;; Tern http://ternjs.net/doc/manual.html#emacs
(setenv "PATH" (concat (getenv "PATH") ":/home/brolin/.nvm/versions/node/v4.1.2/bin"))
(setq exec-path (append exec-path '("/home/brolin/.nvm/versions/node/v4.1.2/bin")))
(add-hook 'js2-mode-hook (lambda () (tern-mode t)))
(eval-after-load 'tern
'(progn
(require 'tern-auto-complete)
(tern-ac-setup)))
;; ES mode https://github.com/dakrone/es-mode
(autoload 'es-mode "es-mode.el"
"Major mode for editing Elasticsearch queries" t)
(add-to-list 'auto-mode-alist '("\\.es$" . es-mode))
(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.
'(temporary-file-directory "~/.emacs.d/vendor/emacs.js/tmp"))
;; React snippets https://github.com/johnmastro/react-snippets.el
(require 'react-snippets)
(defun modify-syntax-table-for-jsx ()
(modify-syntax-entry ?< "(>")
(modify-syntax-entry ?> ")<"))
(add-hook 'js2-mode-hook 'modify-syntax-table-for-jsx)
(eval-after-load 'js2-mode
'(sp-local-pair 'js2-mode "<" ">"))
(eval-after-load 'js2-mode
'(progn
(require 'js2-imenu-extras)
;; The code to record the class is identical to that for
;; Backbone so we just make an alias
(defalias 'js2-imenu-record-react-class
'js2-imenu-record-backbone-extend)
(unless (loop for entry in js2-imenu-extension-styles
thereis (eq (plist-get entry :framework) 'react))
(push '(:framework react
:call-re "\\_<React\\.createClass\\s-*("
:recorder js2-imenu-record-react-class)
js2-imenu-extension-styles))
(add-to-list 'js2-imenu-available-frameworks 'react)
(add-to-list 'js2-imenu-enabled-frameworks 'react)))
;; https://github.com/ZachMassia/platformio-mode
;; Add the required company backend.
(add-to-list 'company-backends 'company-irony)
;; Enable irony and platformio for all c++ files.
(add-hook 'c++-mode-hook (lambda ()
(irony-mode)
(irony-eldoc)
(platformio-mode)))
;; Use irony's completion functions.
(add-hook 'irony-mode-hook
(lambda ()
(define-key irony-mode-map [remap completion-at-point]
'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
'irony-completion-at-point-async)
(irony-cdb-autosetup-compile-options)))
;; Setup irony for flycheck.
(add-hook 'flycheck-mode-hook 'flycheck-irony-setup)
;; Enable scrolling and colours in the compile buffer.
(platformio-setup-compile-buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment