 (add-to-list 'package-archives
    '("melpa" . "http://melpa.milkbox.net/packages/") t)
 (add-to-list 'package-archives
-             '("marmalade" . "http://marmalade-repo.org/packages/") t)
-(setq mac-option-key-is-meta nil)
-(setq mac-command-key-is-meta t)
-(setq mac-command-modifier 'meta)
-(setq mac-option-modifier nil)
+   '("marmalade" . "http://marmalade-repo.org/packages/") t)
+(defvar mac-option-key-is-meta nil)
+(defvar mac-command-key-is-meta t)
+(defvar mac-command-modifier 'meta)
+(defvar mac-option-modifier nil)
 (custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.

;     (add-to-list 'grep-find-ignored-files "*.class")))

(defun func-region (start end func)
  "run a function over the region between START and END in current buffer."
  (save-excursion
    (let ((text (delete-and-extract-region start end)))
      (insert (funcall func text)))))

(defun urlencode (start end)
  "urlencode the region between START and END in current buffer."
  (interactive "r")
  (func-region start end #'url-hexify-string))

(defun urldecode (start end)
  "de-urlencode the region between START and END in current buffer."
  (interactive "r")
  (func-region start end #'url-unhex-string))

;; XML pretty printer, requires nXML mode
(defun pretty-print-xml-region (begin end)
  "Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this.  The function inserts linebreaks to separate tags that have
nothing but whitespace between them.  It then indents the markup
by using nxml's indentation rules."

(global-linum-mode 1) ; Show line numbers
(column-number-mode 1) ; Show cursor column position
(desktop-save-mode 1) ; Save/restore opened buffers

;; Enable minor modes for given major modes
(defun default-minor-modes ()
  "Enable several minor modes that are generally applicable."
  (interactive)
  (flycheck-mode)
  (company-mode)
  (helm-mode)
  (rainbow-mode)
  )
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'web-mode 'default-minor-modes)
(add-hook 'python-mode-hook 'default-minor-modes)
(add-hook 'ruby-mode-hook 'default-minor-modes)
(add-hook 'emacs-lisp-mode-hook 'default-minor-modes)
(add-hook 'javascript-mode-hook 'default-minor-modes)
(add-hook 'javascript-mode-hook 'tern-mode)


;; Use regex searches by default.
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
