Skip to content

Instantly share code, notes, and snippets.

@ssanderson
Created May 7, 2014 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssanderson/37454a9c41c5a0c5a1d2 to your computer and use it in GitHub Desktop.
Save ssanderson/37454a9c41c5a0c5a1d2 to your computer and use it in GitHub Desktop.
;; Root directory for Quantopian projects.
(setq quantopian-root
(let (temp)
(setq temp (getenv "QUANTO_ROOT"))
(if temp (file-name-as-directory temp) "~/quantopian")))
;; =============
;; Package Repos
;; =============
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/"))
;; Show matching parens/braces under point.
(require 'paren)
(show-paren-mode t)
(setq show-paren-delay 0)
;; ================
;; Custom functions
;; ================
(defun qtags ()
"Run etags on Quantopian python source file."
(interactive)
(shell-command
(format
"find %s -and -and -name '*.py' -not -name '*\.pyc' -not -name '*__init__.py' | xargs etags -o %s"
quantopian-root (concat quantopian-root "TAGS"))))
(defun qgrep ()
"Grep for regex in python files within the value specified for"
"quantopian-root. Uses grep-find for built-in history."
(interactive)
(let (sym regex grep-fmt grep-flags)
;; Interactively get a regex to search for, using the symbol under the
;; point as a default.
(setq sym (thing-at-point 'symbol))
(setq regex (read-regexp "Expression" sym))
(setq grep-flags "-nH")
(setq grep-fmt "find %s -type f '(' -name \"*.py\" -or -name \"*.sh\" ')' \
-and -not -name \"*.pyc\" -exec grep %s --color=auto -e \"%s\" {} +")
;; Grep for the specified regex in .py and .sh files within quantopian-root.
(grep-find (format grep-fmt quantopian-root grep-flags regex))))
(defun iqgrep ()
"Grep for regex in python files within the value specified for"
"quantopian-root. Uses grep-find for built-in history."
(interactive)
(let (sym regex grep-fmt grep-flags)
;; Interactively get a regex to search for, using the symbol under the
;; point as a default.
(setq sym (thing-at-point 'symbol))
(setq regex (read-regexp "Expression" sym))
(setq grep-flags "-niH")
(setq grep-fmt "find %s -type f '(' -name \"*.py\" -or -name \"*.sh\" ')' \
-and -not -name \"*.pyc\" -exec grep %s --color=auto -e \"%s\" {} +")
;; Grep for the specified regex in .py and .sh files within quantopian-root.
(grep-find (format grep-fmt quantopian-root grep-flags regex))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment