summaryrefslogtreecommitdiffstats
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Tom Willemse2015-12-18 20:45:28 +0100
committerGravatar Tom Willemse2015-12-18 20:45:28 +0100
commit0258e9aa5a66948f9a69507a2ad56fbe15ae93f0 (patch)
tree63a98035ca95fd6aa0e10141172b5503888054fd /emacs
parent5a9ed5919515bac0344a03cf66ce9217cd39080d (diff)
downloaddotfiles-0258e9aa5a66948f9a69507a2ad56fbe15ae93f0.tar.gz
dotfiles-0258e9aa5a66948f9a69507a2ad56fbe15ae93f0.zip
Move some functions to the Python library
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init.el36
-rw-r--r--emacs/.emacs.d/site-lisp/oni-python.el23
2 files changed, 40 insertions, 19 deletions
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index 1c84fb7..82e9305 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -141,21 +141,6 @@ MODE1 is enabled and vice-versa."
"Set the `disabled' property for each item in FUNCTIONS to nil."
(mapc #'(lambda (f) (put f 'disabled nil)) functions))
-(defun oni:set-python-imenu-function ()
- "Set the `imenu-create-index-function' variable.
-
-For `python-mode' I prefer `python-imenu-create-flat-index'."
- (setq imenu-create-index-function #'python-imenu-create-flat-index))
-
-(defun oni:set-python-symbols ()
- "Set a few extra UTF-8 symbols for use in python."
- (when (boundp 'prettify-symbols-alist)
- (setq prettify-symbols-alist
- '(("lambda" . ?λ)
- ("<=" . ?≤)
- (">=" . ?≥)
- ("!=" . ?≠)))))
-
(defun oni:set-tab-maybe-toggle-outline ()
"Wrap the current function mapped to `TAB'."
(let ((func (or (lookup-key (current-local-map) (kbd "TAB"))
@@ -770,10 +755,23 @@ If no direction is given, don't split."
'oni:maybe-fci-mode #'rainbow-delimiters-mode
'oni:maybe-prettify-symbols-mode)
-(oni:add-hooks 'python-mode-hook
- (lambda () (setq ac-sources '(ac-source-jedi-direct)))
- #'oni:set-python-symbols #'whitespace-mode
- #'oni:set-python-imenu-function #'jedi:setup #'subword-mode)
+;; Set autocompletion sources for Python
+(add-hook 'python-mode-hook 'oni:set-python-completion-sources)
+
+;; Set prettify-symbols symbols for Python
+(add-hook 'python-mode-hook 'oni:set-python-symbols)
+
+;; Use whitespace-mode in Python buffers
+(add-hook 'python-mode-hook 'whitespace-mode)
+
+;; Set the preferred imenu function for Python
+(add-hook 'python-mode-hook 'oni:set-python-imenu-function)
+
+;; Enable jedi in Python buffers
+(add-hook 'python-mode-hook 'jedi:setup)
+
+;; Enable subword-mode in Python buffers
+(add-hook 'python-mode-hook 'subword-mode)
(oni:add-hooks 'slime-repl-mode-hook
#'paredit-mode #'set-up-slime-ac)
diff --git a/emacs/.emacs.d/site-lisp/oni-python.el b/emacs/.emacs.d/site-lisp/oni-python.el
index 7dc6f21..e2cc7d6 100644
--- a/emacs/.emacs.d/site-lisp/oni-python.el
+++ b/emacs/.emacs.d/site-lisp/oni-python.el
@@ -25,6 +25,7 @@
;;; Code:
+(require 'auto-complete)
(require 'fill-column-indicator)
(require 'python)
(require 'whitespace)
@@ -94,6 +95,28 @@
(setq-local fci-rule-column 79))
;;;###autoload
+(defun oni:set-python-completion-sources ()
+ "Set `ac-sources' to python-specific sources."
+ (setq ac-sources '(ac-source-jedi-direct)))
+
+;;;###autoload
+(defun oni:set-python-imenu-function ()
+ "Set the `imenu-create-index-function' variable.
+
+For `python-mode' I prefer `python-imenu-create-flat-index'."
+ (setq imenu-create-index-function #'python-imenu-create-flat-index))
+
+;;;###autoload
+(defun oni:set-python-symbols ()
+ "Set a few extra UTF-8 symbols for use in python."
+ (when (boundp 'prettify-symbols-alist)
+ (setq prettify-symbols-alist
+ '(("lambda" . ?λ)
+ ("<=" . ?≤)
+ (">=" . ?≥)
+ ("!=" . ?≠)))))
+
+;;;###autoload
(defun oni:set-whitespace-tab-display ()
"Set the `whitespace-style' to show only tabs."
(setq-local whitespace-style '(tab-mark)))