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.

120 lines
3.8 KiB

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. (require 'recentf)
  30. (recentf-mode 1)
  31. (global-set-key (kbd "C-<tab>") 'recentf-open-files)
  32. (global-set-key (kbd "C-x g") 'magit-status)
  33. (setq inhibit-startup-screen t)
  34. (setq ls-lisp-use-insert-directory-program t) ;; use external ls
  35. (cond
  36. ;; Windows fixes
  37. ((string-equal system-type "windows-nt")
  38. (progn
  39. (setq insert-directory-program "C:/Program Files/git/usr/bin/ls.exe")
  40. (defun quote-exe (path)
  41. (w32-short-file-name path))
  42. (setq python-shell-interpreter (quote-exe (executable-find "python")))
  43. (setq python-check-command (quote-exe (executable-find "flake8")))
  44. ))
  45. ;; Linux-specific
  46. ((string-equal system-type "gnu/linux")
  47. (progn
  48. (setq elpy-interactive-command (executable-find "python3"))
  49. (setq elpy-rpc-python-command elpy-interactive-command)
  50. )))
  51. (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)
  52. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  53. ;; --------------------------------------
  54. ; (setq inhibit-startup-message t) ;; hide the startup message
  55. ; (load-theme 'material t) ;; load material theme
  56. (load-theme 'dracula t)
  57. (global-linum-mode t) ;; enable line numbers globally
  58. ;; PYTHON CONFIGURATION
  59. ;; --------------------------------------
  60. (elpy-enable)
  61. ;(debug-on-variable-change 'python-check-command)
  62. ; (elpy-use-ipython)
  63. ;; use flycheck not flymake with elpy
  64. (when (require 'flycheck nil t)
  65. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  66. (add-hook 'elpy-mode-hook 'flycheck-mode))
  67. ;; enable py-autopep8 formatting on save
  68. (require 'py-autopep8)
  69. (defun python-mode-keys ()
  70. "Modify python-mode local key map"
  71. (local-set-key (kbd "C-c C-p") 'py-autopep8))
  72. (add-hook 'python-mode-hook 'python-mode-keys)
  73. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  74. ;(setq python-flymake-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  75. ;(setq python-check-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  76. ; (setq elpy-rpc-python-command "\"c:/Program Files/Python37/pythonw.exe\" ")
  77. (setq elpy-syntax-check-command python-check-command)
  78. ;; init.el ends here
  79. (custom-set-variables
  80. ;; custom-set-variables was added by Custom.
  81. ;; If you edit it by hand, you could mess it up, so be careful.
  82. ;; Your init file should contain only one such instance.
  83. ;; If there is more than one, they won't work right.
  84. '(custom-safe-themes
  85. (quote
  86. ("274fa62b00d732d093fc3f120aca1b31a6bb484492f31081c1814a858e25c72e" default)))
  87. '(package-selected-packages
  88. (quote
  89. (python-django django-mode visual-regexp-steroids pcre2el vimrc-mode iedit transient magit dracula-theme py-autopep8 flycheck elpy ein better-defaults))))
  90. (custom-set-faces
  91. ;; custom-set-faces was added by Custom.
  92. ;; If you edit it by hand, you could mess it up, so be careful.
  93. ;; Your init file should contain only one such instance.
  94. ;; If there is more than one, they won't work right.
  95. )
  96. ;; Monkey patch
  97. ;(defun quote-exe (path)
  98. ; (if (string-match-p (regexp-quote " ") path)
  99. ; (shell-quote-argument path)
  100. ; path))
  101. ;(defun quote-exe (path)
  102. ; (replace-regexp-in-string " " "\\ " path)
  103. ;
  104. ;(advice-add 'executable-find :filter-return #'quote-exe)