Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
4.3 KiB

7 years ago
7 years ago
7 years ago
7 years ago
  1. ;; init.el --- Emacs configuration
  2. ;; INSTALL PACKAGES
  3. ;; --------------------------------------
  4. (require 'package)
  5. (add-to-list 'package-archives
  6. '("melpa" . "http://melpa.org/packages/") t)
  7. (package-initialize)
  8. (when (not package-archive-contents)
  9. (package-refresh-contents))
  10. (defvar myPackages
  11. '(better-defaults
  12. ein
  13. elpy
  14. flycheck
  15. magit
  16. ; material-theme
  17. dracula-theme
  18. yaml-mode
  19. py-autopep8
  20. apache-mode
  21. visual-regexp-steroids))
  22. (mapc #'(lambda (package)
  23. (unless (package-installed-p package)
  24. (package-install package)))
  25. myPackages)
  26. ;; BASIC
  27. (require 'yaml-mode)
  28. (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
  29. (global-set-key (kbd "C-c <left>") 'windmove-left)
  30. (global-set-key (kbd "C-c <right>") 'windmove-right)
  31. (global-set-key (kbd "C-c <up>") 'windmove-up)
  32. (global-set-key (kbd "C-c <down>") 'windmove-down)
  33. (defun duplicate-line()
  34. (interactive)
  35. (move-beginning-of-line 1)
  36. (kill-line)
  37. (yank)
  38. (open-line 1)
  39. (next-line 1)
  40. (yank)
  41. )
  42. (global-set-key (kbd "C-c C-d") 'duplicate-line)
  43. (require 'recentf)
  44. (recentf-mode 1)
  45. (global-set-key (kbd "C-<tab>") 'recentf-open-files)
  46. (global-set-key (kbd "C-x g") 'magit-status)
  47. (setq inhibit-startup-screen t)
  48. (setq ls-lisp-use-insert-directory-program t) ;; use external ls
  49. (cond
  50. ;; Windows fixes
  51. ((string-equal system-type "windows-nt")
  52. (progn
  53. (defun quote-exe (path)
  54. (w32-short-file-name path))
  55. (setq insert-directory-program "C:/Program Files/git/usr/bin/ls.exe")
  56. (setq find-program (quote-exe "C:/Program Files/git/usr/bin/find.exe"))
  57. (setq grep-program (quote-exe "C:/Program Files/git/usr/bin/grep.exe"))
  58. (setq python-shell-interpreter (quote-exe (executable-find "python")))
  59. (setq python-check-command (quote-exe (executable-find "flake8")))
  60. ))
  61. ;; Linux-specific
  62. ((string-equal system-type "gnu/linux")
  63. (progn
  64. (setq python-shell-interpreter "python3")
  65. (setq elpy-rpc-python-command python-shell-interpreter)
  66. )))
  67. (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)
  68. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  69. ;; --------------------------------------
  70. ; (setq inhibit-startup-message t) ;; hide the startup message
  71. ; (load-theme 'material t) ;; load material theme
  72. (load-theme 'dracula t)
  73. (global-linum-mode t) ;; enable line numbers globally
  74. ;; PYTHON CONFIGURATION
  75. ;; --------------------------------------
  76. (elpy-enable)
  77. ;(debug-on-variable-change 'python-check-command)
  78. ; (elpy-use-ipython)
  79. ;; use flycheck not flymake with elpy
  80. (when (require 'flycheck nil t)
  81. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  82. (add-hook 'elpy-mode-hook 'flycheck-mode))
  83. ;; enable py-autopep8 formatting on save
  84. (require 'py-autopep8)
  85. (defun python-mode-keys ()
  86. "Modify python-mode local key map"
  87. (local-set-key (kbd "C-c C-p") 'py-autopep8))
  88. (add-hook 'python-mode-hook 'python-mode-keys)
  89. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  90. ;(setq python-flymake-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  91. ;(setq python-check-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  92. ; (setq elpy-rpc-python-command "\"c:/Program Files/Python37/pythonw.exe\" ")
  93. (setq elpy-syntax-check-command python-check-command)
  94. ;; init.el ends here
  95. (custom-set-variables
  96. ;; custom-set-variables was added by Custom.
  97. ;; If you edit it by hand, you could mess it up, so be careful.
  98. ;; Your init file should contain only one such instance.
  99. ;; If there is more than one, they won't work right.
  100. '(custom-safe-themes
  101. (quote
  102. ("274fa62b00d732d093fc3f120aca1b31a6bb484492f31081c1814a858e25c72e" default)))
  103. '(package-selected-packages
  104. (quote
  105. (python-django django-mode visual-regexp-steroids pcre2el vimrc-mode iedit transient magit dracula-theme py-autopep8 flycheck elpy ein better-defaults))))
  106. (custom-set-faces
  107. ;; custom-set-faces was added by Custom.
  108. ;; If you edit it by hand, you could mess it up, so be careful.
  109. ;; Your init file should contain only one such instance.
  110. ;; If there is more than one, they won't work right.
  111. )
  112. ;; Monkey patch
  113. ;(defun quote-exe (path)
  114. ; (if (string-match-p (regexp-quote " ") path)
  115. ; (shell-quote-argument path)
  116. ; path))
  117. ;(defun quote-exe (path)
  118. ; (replace-regexp-in-string " " "\\ " path)
  119. ;
  120. ;(advice-add 'executable-find :filter-return #'quote-exe)