From 54577f4f7ccd88348a31fe0c8893bf203bcf4926 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 29 Jun 2013 01:35:43 -0400 Subject: move python shebang/common imports to yasnippet --- init/km-python.el | 22 ---------------------- snippets/python-mode/dat | 6 ++++++ snippets/python-mode/plt | 8 ++++++++ snippets/python-mode/shebang | 5 +++++ 4 files changed, 19 insertions(+), 22 deletions(-) create mode 100644 snippets/python-mode/dat create mode 100644 snippets/python-mode/plt create mode 100644 snippets/python-mode/shebang diff --git a/init/km-python.el b/init/km-python.el index 9940611..8d5271a 100644 --- a/init/km-python.el +++ b/init/km-python.el @@ -1,25 +1,3 @@ -(defun km/python-shebang () - (interactive) - (km/shebang "python")) - -(defconst km/python-analysis-imports - "import numpy as np -import pandas as pd -import matplotlib.pyplot as plt -from matplotlib import ticker - -from colors import brew, fgry, bgry") - -(defun km/python-insert-analysis-imports () - "Common imports for analysis scripts" - (interactive) - (insert km/python-analysis-imports)) - -(defun km/python-hook () - (local-set-key (kbd "C-c p s") 'km/python-shebang) - (local-set-key (kbd "C-c p a") 'km/python-insert-analysis-imports)) -(add-hook 'python-mode-hook 'km/python-hook) - ;; http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc5 (setq python-shell-interpreter "ipython" diff --git a/snippets/python-mode/dat b/snippets/python-mode/dat new file mode 100644 index 0000000..bb96f33 --- /dev/null +++ b/snippets/python-mode/dat @@ -0,0 +1,6 @@ +# name: data analysis imports +# key: dat +# -- +import numpy as np +import pandas as pd +$0 diff --git a/snippets/python-mode/plt b/snippets/python-mode/plt new file mode 100644 index 0000000..434e09c --- /dev/null +++ b/snippets/python-mode/plt @@ -0,0 +1,8 @@ +# name: matplotlib-related import +# key: plt +# -- +import matplotlib.pyplt as plt +from matplotlib import tickers + +import pltaid +$0 diff --git a/snippets/python-mode/shebang b/snippets/python-mode/shebang new file mode 100644 index 0000000..26da506 --- /dev/null +++ b/snippets/python-mode/shebang @@ -0,0 +1,5 @@ +# name: python shebang +# key: #! +# -- +#!/usr/bin/env python${1:3} +$0 -- cgit v1.2.3