Move python-mode-func to Python library
This commit is contained in:
parent
9a626be7a4
commit
86e8b03592
2 changed files with 39 additions and 11 deletions
|
@ -141,15 +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:python-mode-func ()
|
|
||||||
"Function for `python-mode-hook'."
|
|
||||||
(local-set-key (kbd "C->") 'python-indent-shift-right)
|
|
||||||
(local-set-key (kbd "C-<") 'python-indent-shift-left)
|
|
||||||
(set (make-local-variable 'electric-indent-chars) nil)
|
|
||||||
(setq-local fci-rule-column 79)
|
|
||||||
(setq-local fill-column 72)
|
|
||||||
(setq-local whitespace-style '(tab-mark)))
|
|
||||||
|
|
||||||
(defun oni:raise-ansi-term (arg)
|
(defun oni:raise-ansi-term (arg)
|
||||||
"Create or show an `ansi-term' buffer."
|
"Create or show an `ansi-term' buffer."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
|
@ -873,6 +864,16 @@ If no direction is given, don't split."
|
||||||
;; Only autofill comments in programming buffers.
|
;; Only autofill comments in programming buffers.
|
||||||
(add-hook 'prog-mode-hook 'oni:auto-fill-only-comments)
|
(add-hook 'prog-mode-hook 'oni:auto-fill-only-comments)
|
||||||
|
|
||||||
|
;; Set Python mode-specific keybindings.
|
||||||
|
(add-hook 'python-mode-hook 'oni:set-keys-for-python)
|
||||||
|
|
||||||
|
;; Set PEP 8 margin settings for Python
|
||||||
|
(add-hook 'python-mode-hook 'oni:set-pep8-margin)
|
||||||
|
(add-hook 'python-mode-hook 'oni:set-pep8-fill-column)
|
||||||
|
|
||||||
|
;; Make `whitespace-mode' show tabs
|
||||||
|
(add-hook 'python-mode-hook 'oni:set-whitespace-tab-display)
|
||||||
|
|
||||||
(oni:add-function-to-hooks 'oni:make-readable
|
(oni:add-function-to-hooks 'oni:make-readable
|
||||||
'Info-mode-hook 'gnus-article-mode-hook 'gnus-group-mode-hook
|
'Info-mode-hook 'gnus-article-mode-hook 'gnus-group-mode-hook
|
||||||
'org-agenda-mode-hook)
|
'org-agenda-mode-hook)
|
||||||
|
@ -934,8 +935,7 @@ If no direction is given, don't split."
|
||||||
(oni:add-hooks 'python-mode-hook
|
(oni:add-hooks 'python-mode-hook
|
||||||
(lambda () (setq ac-sources '(ac-source-jedi-direct)))
|
(lambda () (setq ac-sources '(ac-source-jedi-direct)))
|
||||||
#'oni:set-python-symbols #'whitespace-mode
|
#'oni:set-python-symbols #'whitespace-mode
|
||||||
#'oni:python-mode-func #'oni:set-python-imenu-function
|
#'oni:set-python-imenu-function #'jedi:setup #'subword-mode)
|
||||||
#'jedi:setup #'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)
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'fill-column-indicator)
|
||||||
(require 'python)
|
(require 'python)
|
||||||
|
(require 'whitespace)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun oni:add-import-from (package import)
|
(defun oni:add-import-from (package import)
|
||||||
|
@ -49,6 +51,11 @@
|
||||||
(match-end 1)) results)))
|
(match-end 1)) results)))
|
||||||
results))
|
results))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun oni:clear-electric-indent-chars ()
|
||||||
|
"Clear the `electric-indent-chars' which don't work well in Python."
|
||||||
|
(set (make-local-variable 'electric-indent-chars) nil))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun oni:make-import-multiline (from-point to-point)
|
(defun oni:make-import-multiline (from-point to-point)
|
||||||
"Turn an import statement into a multi-line import statement."
|
"Turn an import statement into a multi-line import statement."
|
||||||
|
@ -70,6 +77,27 @@
|
||||||
(forward-line -1)
|
(forward-line -1)
|
||||||
(oni:sort-imports)))
|
(oni:sort-imports)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun oni:set-keys-for-python ()
|
||||||
|
"Set Python mode-specific keybindings."
|
||||||
|
(define-key python-mode-map (kbd "C->") #'python-indent-shift-right)
|
||||||
|
(define-key python-mode-map (kbd "C-<") #'python-indent-shift-left))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun oni:set-pep8-fill-column ()
|
||||||
|
"Set the `fill-column' to the PEP 8 recommendation."
|
||||||
|
(setq-local fill-column 72))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun oni:set-pep8-margin ()
|
||||||
|
"Set the `fci-rule-column' the the PEP 8 recommendation."
|
||||||
|
(setq-local fci-rule-column 79))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun oni:set-whitespace-tab-display ()
|
||||||
|
"Set the `whitespace-style' to show only tabs."
|
||||||
|
(setq-local whitespace-style '(tab-mark)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun oni:sort-imports ()
|
(defun oni:sort-imports ()
|
||||||
"Sort python multiline imports using `()'."
|
"Sort python multiline imports using `()'."
|
||||||
|
|
Loading…
Reference in a new issue