Skip to content

Instantly share code, notes, and snippets.

@gsathya
Created October 6, 2011 11:26
Show Gist options
  • Save gsathya/1267182 to your computer and use it in GitHub Desktop.
Save gsathya/1267182 to your computer and use it in GitHub Desktop.
;; Load Path
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/")
;; Change directory for auto-save files
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;; Use python-mode for .py files
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(require 'ipython)
;; Use anything.el for code completion - Doesn't work
(require 'anything)
(require 'anything-ipython)
(when (require 'anything-show-completion nil t)
(use-anything-show-completion 'anything-ipython-complete
'(length initial-pattern)))
(add-hook 'python-mode-hook #'(lambda ()
(define-key py-mode-map (kbd "M-<tab>") 'anything-ipython-complete)))
(add-hook 'ipython-shell-hook #'(lambda ()
(define-key py-mode-map (kbd "M-<tab>") 'anything-ipython-complete)))
(when (require 'anything-show-completion nil t)
(use-anything-show-completion 'anything-ipython-complete
'(length initial-pattern)))
;; Use up, down arrow keys to cycle buffer
(require 'comint)
(define-key comint-mode-map (kbd "M-") 'comint-next-input)
(define-key comint-mode-map (kbd "M-") 'comint-previous-input)
(define-key comint-mode-map [down] 'comint-next-matching-input-from-input)
(define-key comint-mode-map [up] 'comint-previous-matching-input-from-input)
;; Pylookup for browsing pydocs
(autoload 'pylookup-lookup "pylookup")
(autoload 'pylookup-update "pylookup")
(setq pylookup-program "~/.emacs.d/pylookup/pylookup.py")
(setq pylookup-db-file "~/.emacs.d/pylookup/pylookup.db")
(global-set-key "\C-ch" 'pylookup-lookup)
;; Add matching parenthesis,single and triple quotes automatically
(autoload 'autopair-global-mode "autopair" nil t)
(autopair-global-mode)
(add-hook 'python-mode-hook
#'(lambda ()
(push '(?' . ?')
(getf autopair-extra-pairs :code))
(setq autopair-handle-action-fns
(list #'autopair-default-handle-action
#'autopair-python-triple-quote-action))))
;; Delete trailing white space - Pylint may shout w/o it
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; PEP8 and Pylint to check code quality
(require 'python-pep8)
(require 'python-pylint)
;; Enable yasnippet, loads snippets from /my-snippets/
(require 'yasnippet-bundle)
(yas/initialize)
(yas/load-directory "~/.emacs.d/my-snippets/")
;; Use emacs-w3m to browse links inside emacs
(setq browse-url-browser-function 'w3m-browse-url)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;; Don't show the startup screen
(setq inhibit-startup-message t)
;; "y or n" instead of "yes or no"
(fset 'yes-or-no-p 'y-or-n-p)
;; Display line and column numbers
(setq line-number-mode t)
(setq column-number-mode t)
;; Emacs gurus don't need no stinking scroll bars
(when (fboundp 'toggle-scroll-bar)
(toggle-scroll-bar -1))
;; Prevent the annoying beep on errors
(setq visible-bell t)
;; Gotta see matching parens
(show-paren-mode t)
;; Load color-theme
(require 'color-theme)
;; Color-theme-molokai is set
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(color-theme-molokai)))
;; Add Gist support
(require 'gist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment