Move some functions to the Python library

This commit is contained in:
Tom Willemse 2015-12-18 20:45:28 +01:00
parent 5a9ed59195
commit 0258e9aa5a
2 changed files with 40 additions and 19 deletions

View file

@ -141,21 +141,6 @@ MODE1 is enabled and vice-versa."
"Set the `disabled' property for each item in FUNCTIONS to nil." "Set the `disabled' property for each item in FUNCTIONS to nil."
(mapc #'(lambda (f) (put f 'disabled nil)) functions)) (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 () (defun oni:set-tab-maybe-toggle-outline ()
"Wrap the current function mapped to `TAB'." "Wrap the current function mapped to `TAB'."
(let ((func (or (lookup-key (current-local-map) (kbd "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-fci-mode #'rainbow-delimiters-mode
'oni:maybe-prettify-symbols-mode) 'oni:maybe-prettify-symbols-mode)
(oni:add-hooks 'python-mode-hook ;; Set autocompletion sources for Python
(lambda () (setq ac-sources '(ac-source-jedi-direct))) (add-hook 'python-mode-hook 'oni:set-python-completion-sources)
#'oni:set-python-symbols #'whitespace-mode
#'oni:set-python-imenu-function #'jedi:setup #'subword-mode) ;; 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 (oni:add-hooks 'slime-repl-mode-hook
#'paredit-mode #'set-up-slime-ac) #'paredit-mode #'set-up-slime-ac)

View file

@ -25,6 +25,7 @@
;;; Code: ;;; Code:
(require 'auto-complete)
(require 'fill-column-indicator) (require 'fill-column-indicator)
(require 'python) (require 'python)
(require 'whitespace) (require 'whitespace)
@ -93,6 +94,28 @@
"Set the `fci-rule-column' the the PEP 8 recommendation." "Set the `fci-rule-column' the the PEP 8 recommendation."
(setq-local fci-rule-column 79)) (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 ;;;###autoload
(defun oni:set-whitespace-tab-display () (defun oni:set-whitespace-tab-display ()
"Set the `whitespace-style' to show only tabs." "Set the `whitespace-style' to show only tabs."