Skip to content

Instantly share code, notes, and snippets.

@fzerorubigd
Created June 23, 2012 10:35
Show Gist options
  • Save fzerorubigd/2977839 to your computer and use it in GitHub Desktop.
Save fzerorubigd/2977839 to your computer and use it in GitHub Desktop.
;Add ~/.emacs.d/lisp to load-path
(add-to-list 'load-path "/usr/share/emacs/24.1.50/lisp")
(add-to-list 'load-path "~/.emacs.d/lisp")
;;====================================================================================
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
;;====================================================================================
;;Setup color theme
(require 'color-theme)
(color-theme-initialize)
;; test for each frame or console
(defun color-theme-for-win-sys (frame)
(let ((color-theme-is-global nil))
(select-frame frame)
(when (window-system frame)
(color-theme-sanityinc-solarized-dark))))
;; hook on after-make-frame-functions
(add-hook 'after-make-frame-functions 'color-theme-for-win-sys)
;; Start up the color theme in this initial frame.
(let ((color-theme-is-global nil))
(when (window-system)
(color-theme-sanityinc-solarized-dark)))
;;====================================================================================
;;Setup sr-speedbar binding
(load-library "sr-speedbar")
(global-set-key (kbd "<f11>") 'sr-speedbar-toggle)
(setq speedbar-show-unknown-files t)
(setq speedbar-use-images nil)
(setq sr-speedbar-right-side nil)
;;====================================================================================
;;Setup php-mode-autoload
(load-library "php-mode")
(load-library "php-mode-autoloads")
;;====================================================================================
;;Setup gpicker
(require 'gpicker)
(global-set-key (kbd "C-x C-g p") 'gpicker-visit-project)
(global-set-key (kbd "M-g") 'gpicker-find-file)
(global-set-key (kbd "C-x g") 'gpicker-find-file-other-window)
;;====================================================================================
;;Setup geben
(autoload 'geben "geben" "PHP Debugger on Emacs" t)
;;====================================================================================
;;Setup buffer menu+
(require 'buff-menu+)
(global-set-key (kbd "<menu>") 'buffer-menu)
;;====================================================================================
;;Setup auto complete
(load-library "auto-complete-config")
(ac-config-default)
;;====================================================================================
;;Setup php-doc
(require 'php-doc nil t)
(setq php-doc-directory "~/.emacs.d/php-chunked-xhtml")
(add-hook 'php-mode-hook
(lambda ()
(local-set-key "\t" 'php-doc-complete-function)
(local-set-key (kbd "\C-c h") 'php-doc)
(set (make-local-variable 'eldoc-documentation-function)
'php-doc-eldoc-function)
(eldoc-mode 1)))
;;====================================================================================
;;Setup Moz minor mode, just for fun :D
(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
;;====================================================================================
;;Setup Rainbow mode css (kinda liked it)
(require 'rainbow-mode)
;; CSS and Rainbow modes
(defun all-css-modes() (css-mode) (rainbow-mode))
;; Load both major and minor modes in one call based on file type
(add-to-list 'auto-mode-alist '("\\.css$" . all-css-modes))
;;====================================================================================
;;Setup flymake-phpcs
(require 'flymake-phpcs)
(setq flymake-phpcs-command "~/.emacs.d/bin/flymake_phpcs")
;; Show the name of sniffs in warnings (eg show
;; "Generic.CodeAnalysis.VariableAnalysis.UnusedVariable" in an unused
;; variable warning)
(setq flymake-phpcs-show-rule t)
(setq flymake-phpcs-standard "PEAR")
(add-hook 'php-mode-hook 'flymake-mode-on)
;;====================================================================================
;;Setup smarttab -I prefer this over smart-tab, not in marmalade
(add-to-list 'load-path "~/.emacs.d/lisp/smarttabs")
(require 'smarttabs)
(autoload 'smart-tabs-mode "smart-tabs-mode"
"Intelligently indent with tabs, align with spaces!")
(autoload 'smart-tabs-mode-enable "smart-tabs-mode")
(autoload 'smart-tabs-advice "smart-tabs-mode")
;; PHP
(add-hook 'php-mode-hook 'smart-tabs-mode-enable)
(smart-tabs-advice c-indent-line c-basic-offset)
(smart-tabs-advice c-indent-region c-basic-offset)
;; Fuck, just force tab with C-Tab
(global-set-key (kbd "<C-tab>") 'c-indent-line-or-region)
;;====================================================================================
(require 'js2-mode-autoloads)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;;====================================================================================
;;Setup tab bar
(setq tabbar-ruler-global-tabbar 't)
;(setq tabbar-ruler-global-ruler 't)
;(setq tabbar-ruler-popup-menu 't)
;(setq tabbar-ruler-popup-toolbar 't)
(require 'tabbar-ruler)
;;====================================================================================
;; Setup multi webmode
(add-to-list 'load-path "~/.emacs.d/lisp/multi-web-mode")
(require 'multi-web-mode)
(setq mweb-default-major-mode 'html-mode)
(setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
(js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
(css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
(setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
(add-hook 'php-mode-hook (lambda () (mweb-set-default-major-mode 'php-mode)))
(multi-web-global-mode 1)
;;====================================================================================
;; Browse kill ring
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;;====================================================================================
;;My clipboard hack for C-z C-v , C-z C-c for X clipboard
(load-file "~/.emacs.d/lisp/clipboard.el")
;;====================================================================================
;; Misc key bindings
;;
(global-set-key (kbd "<f3>") 'bury-buffer)
(global-set-key (kbd "C-c s") 'toggle-scroll-bar)
(defun yank-pop-forwards (arg)
(interactive "p")
(yank-pop (- arg)))
(global-set-key "\M-Y" 'yank-pop-forwards) ; M-Y (Meta-Shift-Y)
(global-set-key (kbd "C-`") 'delete-window)
(global-set-key (kbd "C-1") 'delete-other-windows)
(global-set-key (kbd "C-<escape>") 'kill-buffer)
;New key bindings, C n for new empty document
(global-set-key (kbd "C-n") 'new-empty-buffer) ; Open New File
(defun new-empty-buffer ()
"Opens a new empty buffer."
(interactive)
(let ((buf (generate-new-buffer "untitled")))
(switch-to-buffer buf)
(funcall (and initial-major-mode))
(setq buffer-offer-save t)))
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)
(global-set-key [M-left] 'windmove-left) ; move to left windnow
(global-set-key [M-right] 'windmove-right) ; move to right window
(global-set-key [M-up] 'windmove-up) ; move to upper window
(global-set-key [M-down] 'windmove-down) ; move to downer window
;;====================================================================================
;;Customize variable by emacs :D
;; note: emacs won't offer to save a buffer that's
;; not associated with a file,
;; even if buffer-modified-p is true.
;; One work around is to define your own my-kill-buffer function
;; that wraps around kill-buffer, and check on the buffer modification
;; status to offer save
;; This custome kill buffer is close-current-buffer.
(setq-default bidi-display-reordering t)
;EMACS SETTINGS
(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.
'(auto-save-default nil)
'(c-default-style "linux")
'(global-linum-mode t)
'(indent-tabs-mode t)
'(inhibit-startup-screen t)
'(menu-bar-mode nil)
'(scroll-bar-mode (quote right))
'(tab-always-indent nil)
'(tab-width 4)
'(tool-bar-mode nil)
'(x-select-enable-clipboard 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