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.

137 lines
4.3 KiB

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