Browse Source

fixes in org and python

master
Marc Pohling 6 years ago
parent
commit
5fcd22172b
1 changed files with 149 additions and 51 deletions
  1. 200
      config.org

200
config.org

@ -60,6 +60,7 @@ Variants dark and light
)
#+end_src
* Sane defaults
Sources for this section include [[https://github.com/magnars/.emacs.d/blob/master/settings/sane-defaults.el][Magnars Sveen]] and [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua]]
@ -70,15 +71,18 @@ These functions are useful. Activate them.
(put 'narrow-to-region 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
#+end_src
Answering just 'y' or 'n' should be enough.
#+begin_src emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p)
#+end_src
Keep all backup and auto-save files in one directory
#+begin_src emacs-lisp
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
#+end_src
UTF-8 please
#+begin_src emacs-lisp
(setq locale-coding-system 'utf-8)
@ -111,6 +115,13 @@ Delete the region when typing, just like as we expect nowadays.
(delete-selection-mode t)
#+end_src
Auto-indent when pressing RET, just new-line when C-j
#+begin_src emacs-lisp
(define-key global-map (kbd "RET") 'newline-and-indent)
(define-key global-map (kbd "C-j") 'newline)
#+end_src
Various stuff
#+begin_src emacs-lisp
(show-paren-mode t)
@ -118,7 +129,7 @@ Various stuff
(global-visual-line-mode)
(diminish 'visual-line-mode)
(setq uniquify-buffer-name-style 'forward)
#+end_src
@ -144,7 +155,14 @@ Although org mode ships with Emacs, the latest version can be installed external
#+begin_src emacs-lisp
(use-package org
:ensure org-plus-contrib)
:ensure org-plus-contrib
:init
(add-hook 'org-mode-hook
(lambda ()
(add-to-list 'company-backends 'company-capf)
(add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
(company-mode t)))
)
#+end_src
To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory:
@ -154,7 +172,7 @@ To avoid problems executing source blocks out of the box. [[https://emacs.stacke
rm ${ORG_DIR}/*.elc
#+end_src
*** Org activation bindings
*** Org key bindings
Set up some global key bindings that integrate with Org mode features
#+begin_src emacs-lisp
@ -163,6 +181,12 @@ Set up some global key bindings that integrate with Org mode features
(bind-key "C-c a" 'org-agenda)
#+end_src
Org overwrites RET and C-j, so I need to disable the rebinds
#+begin_src emacs-lisp
(define-key org-mode-map (kbd "RET") nil) ;;org-return
(define-key org-mode-map (kbd "C-j") nil) ;;org-return-indent
#+end_src
*** Org agenda
For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e473368adb1f63e582a6595450fcd0e787c/Sacha.org#org-agenda][see here]].
@ -263,7 +287,8 @@ Info in Emacs: M-x customize-group which-key
)
#+end_src
* Ido
* Ido (currently inactive)
better completion
begin_src emacs-lisp
@ -287,9 +312,9 @@ end_src
Flx is required for fuzzy-matching
Is it really necessary?
#+begin_src emacs-lisp
begin_src emacs-lisp
(use-package flx)
#+end_src
end_src
Ivy displays a window with suggestions for hotkeys and M-x
@ -345,6 +370,7 @@ Swiper ivy-enhances isearch
)
#+end_src
* Recentf
Requires counsel
#+begin_src emacs-lisp
@ -361,6 +387,40 @@ Requires counsel
** Common things
List of plugins and settings which are shared between the language plugins
Highlight whitespaces, tabs, empty lines.
#+begin_src emacs-lisp
(use-package whitespace
:demand t
:ensure nil
:hook
((prog-mode . whitespace-turn-on)
(text-mode . whitespace-turn-on))
:config
(setq-default whitespace-style '(face empty tab trailing))
)
#+end_src
Disable Eldoc, it interferes with flycheck
#+begin_src emacs-lisp
(use-package eldoc
:ensure nil
:config
(global-eldoc-mode -1)
)
#+end_src
Colorize colors as text with their value
#+begin_src emacs-lisp
(use-package rainbow-mode
:hook prog-mode
:config
(setq-default rainbow-x-colors-major-mode-list '())
)
#+end_src
*** Company Mode
Complete Anything!
@ -370,14 +430,11 @@ Activate company and make it react nearly instantly
(use-package company
:ensure t
:config
(add-to-list 'company-backends 'company-elisp)
(setq-default company-minimum-prefix-length 2
(setq-default company-minimum-prefix-length 1
company-tooltip-align-annotation t
company-tooltop-flip-when-above t
company-show-numbers t
company-idle-delay 0.1)
(add-hook 'after-init-hook 'global-company-mode)
;; (global-company-mode t)
)
#+end_src
@ -426,7 +483,8 @@ The virtual environments need to have following modules installed:
(add-hook 'after-init-hook #'global-flycheck-mode)
(add-hook 'python-mode-hook (lambda ()
(semantic-mode 1)
(setq flycheck-checker 'python-pylint)))
(flycheck-select-checker 'python-pylint)))
;; (setq flycheck-checker 'python-pylint)))
)
#+end_src
@ -435,12 +493,17 @@ Not sure if python.el is better than python-mode.el.
See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
The custom function is to run inferiour processes (do I really need that?), see [[https://emacs.stackexchange.com/questions/16361/how-to-automatically-run-inferior-process-when-loading-major-mode][here]].
Also limit the completion backends to those which make sense in Python.
#+begin_src emacs-lisp
(use-package python
:mode ("\\.py\\'" . python-mode)
:interpreter ("python" . python-mode)
:init
(add-hook 'python-mode-hook 'eldoc-mode)
(add-hook 'python-mode-hook
(lambda ()
;; (set (make-local-variable 'company-backends)
;; '((company-jedi company-dabbrev-code company-capf company-files)))
(company-mode t)))
:config
(setq python-shell-completion-native-enable nil)
;; (defun my/run-python ()
@ -451,36 +514,13 @@ The custom function is to run inferiour processes (do I really need that?), see
)
#+end_src
Anaconda test
begin_src emacs-lisp
(use-package anaconda-mode
:ensure t
:defer t
:init
(add-hook 'python-mode-hook 'anaconda-mode)
;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
:config
(setq anaconda-eldoc-mode 1)
)
end_src
begin_src emacs-lisp
(use-package company-anaconda
:ensure t
:defer t
:init
(defun my/company-anaconda-hook()
(add-to-list 'company-backends 'company-anaconda))
(add-hook 'python-mode-hook 'my/company-anaconda-hook)
)
end_src
Jedi is a backend for python autocompletion and needs to be installed on the server:
- pip install jedi
Code checks need to be installed, too:
- pip install flake8
begin_src emacs-lisp
#+begin_src emacs-lisp
(use-package company-jedi
:defer t
;; :after company
@ -491,9 +531,13 @@ begin_src emacs-lisp
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
(setq jedi:use-shortcuts t)
(defun my/python-mode-hook()
(add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'my/python-mode-hook)
;; (defun my/python-mode-hook()
;; (lambda ()
;; (set (make-local-variable 'company-backends)
;; '((company-jedi company-dabbrev) company-capf company-files))))
;; (add-to-list 'company-backends 'company-jedi))
;; (add-hook 'python-mode-hook 'my/python-mode-hook)
;; (add-hook 'python-mode-hook 'company-mode)
)
#+end_src
@ -517,11 +561,14 @@ apt install
;; default traceback, other option M-x jedi:toggle-log-traceback
;; traceback is in jedi:pop-to-epc-buffer
(jedi:setup)
(setq jedi:server-args '("--log-traceback"))
(setq jedi:server-args '("--log-traceback")))
(add-to-list 'company-backends 'company-jedi)
(add-to-list 'company-backends 'company-anaconda)
;; (add-to-list 'company-backends 'company-anaconda)
;; (lambda ()
;; (set (make-local-variable 'company-backends)
;; '((company-jedi company-dabbrev) company-capf company-files)))
;; (setq flycheck-checker 'python-pylint))
(flycheck-select-checker 'python-pylint))
;; (flycheck-select-checker 'python-pylint))
;; (setq flycheck-checker 'python-flake8)
(add-hook 'pyvenv-post-activate-hooks 'my/post-activate-hook)
)
@ -548,20 +595,71 @@ Depends on pyvenv
)
#+end_src
Anaconda test
begin_src emacs-lisp
(use-package virtualenvwrapper
(use-package anaconda-mode
:ensure t
:defer t
:init
(venv-initialize-interactive-shells)
(venv-initialize-eshell)
(setq venv-location "~/Archiv/Programmierprojekte/Python/virtualenv")
(setq python-environment-directory venv-location)
(add-hook 'venv-postmkvirtualenv-hook
(lambda () (shell-command "pip install epc jedi")))
(add-hook 'venv-postactivate-hook 'jedi:stop-server)
(add-hook 'venv-postdeactivate-hook 'jedi:stop-server)
(add-hook 'python-mode-hook 'anaconda-mode)
;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
:config
(setq anaconda-eldoc-mode 1)
)
end_src
begin_src emacs-lisp
(use-package company-anaconda
:ensure t
:defer t
:init
(defun my/company-anaconda-hook()
(add-to-list 'company-backends 'company-anaconda))
(add-hook 'python-mode-hook 'my/company-anaconda-hook)
)
end_src
* Hydra
Hydra allows grouping of commands
#+begin_src emacs-lisp
(use-package hydra
:ensure t
:bind
("C-c f" . hydra-flycheck/body)
:config
(setq-default hydra-default-hint nil)
)
#+end_src
** Hydra Flycheck
Flycheck is necessary, obviously
#+begin_src emacs-lisp
(defhydra hydra-flycheck (:color blue)
"
^
^Flycheck^ ^Errors^ ^Checker^
^────────^──────────^──────^────────────^───────^───────────
_q_ quit _<_ previous _?_ describe
_m_ manual _>_ next _d_ disable
_v_ verify setup _f_ check _s_ select
^^ ^^ ^^
"
("q" nil)
("<" flycheck-previous-error :color red)
(">" flycheck-next-error :color red)
("?" flycheck-describe-checker)
("d" flycheck-disable-checker)
("f" flycheck-buffer)
("m" flycheck-manual)
("s" flycheck-select-checker)
("v" flycheck-verify-setup)
)
#+end_src
* Quality of Life
Loading…
Cancel
Save