An Emacs configuration to work with LaTeX, Python, C, C++, Pandoc, Markdown, Slack, and git running natively in different OS like MacOS, ArchLinux, and Ubuntu.
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.

212 lines
7.6 KiB

2 years ago
2 years ago
2 years ago
  1. ;;; My basic configuration Gerardo Marx 20/May/2021
  2. ;; MacOS version
  3. ;;--------
  4. ;; Melpa repository:
  5. (require 'package)
  6. (add-to-list 'package-archives
  7. '("melpa" . "https://melpa.org/packages/")t)
  8. (package-initialize)
  9. ;;+++++++++++++
  10. ;;function to check installed packages:
  11. (defun is-installed (pack)
  12. "Check if a package is istalled"
  13. (unless (package-installed-p pack)
  14. (package-refresh-contents)
  15. (package-install pack)))
  16. ;;++++++++++++++++
  17. ;; use-package
  18. (is-installed 'use-package)
  19. (is-installed 'helm)
  20. (require 'helm-config)
  21. (global-set-key (kbd "M-x") 'helm-M-x)
  22. (global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
  23. (global-set-key (kbd "C-x C-f") #'helm-find-files)
  24. (helm-mode 1)
  25. ;;++++++++++++
  26. ;; which-key
  27. (is-installed 'which-key)
  28. (require 'which-key)
  29. (which-key-mode)
  30. ;;+++++++++++++
  31. ;; frame size
  32. ;;(setq initial-frame-alist '((top . 325)(left . 0)
  33. ;; (width . 80)(height . 50)))
  34. ;; set transparency
  35. (set-frame-parameter (selected-frame) 'alpha '(95 . 50))
  36. (add-to-list 'default-frame-alist '(alpha . (95 . 50)))
  37. ;;+++++++++++
  38. ;; Doom-themes, all-the-icons, mode-line and font
  39. (unless (package-installed-p 'doom-themes)
  40. (package-install 'doom-themes))
  41. (unless (package-installed-p 'all-the-icons)
  42. (package-install 'all-the-icons))
  43. (require 'doom-themes)
  44. ;; Global settings (defaults)
  45. (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
  46. doom-themes-enable-italic t) ; if nil, italics is universally disabled
  47. ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each
  48. ;; theme may have their own settings.
  49. (load-theme 'doom-one t)
  50. ;; Enable flashing mode-line on errors
  51. (doom-themes-visual-bell-config)
  52. ;; Enable custom neotree theme
  53. (doom-themes-neotree-config) ; all-the-icons fonts must be installed!
  54. ;; Installling doom-modeline:
  55. (unless (package-installed-p 'doom-modeline)
  56. (package-install 'doom-modeline))
  57. (require 'doom-modeline)
  58. (doom-modeline-mode 1)
  59. ;;Intalling all-the-icons font:
  60. (unless (package-installed-p 'all-the-icons)
  61. (package-install 'all-the-icons))
  62. ;; Set default font:
  63. (add-to-list 'default-frame-alist
  64. '(font . "Source Code Pro-15"))
  65. ;;+++++++
  66. ;;auctex:
  67. (is-installed 'auctex)
  68. (is-installed 'pdf-tools);; PDFtools
  69. (pdf-tools-install)
  70. (setenv "PATH" (concat "/Library/TeX/texbin:"
  71. (getenv "PATH")))
  72. (add-to-list 'exec-path "/Library/TeX/texbin")
  73. (setq TeX-auto-save t)
  74. (setq TeX-save-query nil)
  75. (setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
  76. (setq TeX-parse-self t)
  77. (setq-default TeX-master nil)
  78. (add-hook 'LaTeX-mode-hook 'visual-line-mode)
  79. (add-hook 'LaTeX-mode-hook 'flyspell-mode)
  80. (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
  81. (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
  82. (setq reftex-plug-into-AUCTeX t)
  83. (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
  84. TeX-source-correlate-start-server t)
  85. ;; Update PDF buffers after successful LaTeX runs
  86. (defun framesMenus-display-buffer-use-some-frame (fun &rest args)
  87. "Use `display-buffer-use-some-frame' as `display-buffer-overriding-action'.
  88. Then run FUN with ARGS."
  89. (let ((display-buffer-overriding-action '(display-buffer-use-some-frame)))
  90. (apply fun args)))
  91. (advice-add 'TeX-pdf-tools-sync-view :around #'framesMenus-display-buffer-use-some-frame)
  92. (advice-add 'pdf-sync-backward-search-mouse :around #'framesMenus-display-buffer-use-some-frame)
  93. (add-hook 'TeX-after-compilation-finished-functions
  94. #'TeX-revert-document-buffer)
  95. (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  96. (add-hook 'pdf-view-mode-hook
  97. (lambda () (pdf-tools-enable-minor-modes)))
  98. (setq TeX-source-correlate-method 'synctex)
  99. ;;--end----
  100. ;;..............
  101. ;;========
  102. ;;Flyspell
  103. (setq ispell-program-name "/usr/bin/aspell")
  104. (dolist (hook '(text-mode-hook))
  105. (add-hook hook (lambda () (flyspell-mode 1))))
  106. ;; ==========
  107. ;; ORG files:
  108. (is-installed 'org-ref)
  109. (require 'org-ref)
  110. (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
  111. (setq org-latex-prefer-user-labels t)
  112. ;; ==========
  113. ;; TRMAP
  114. (eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
  115. ;;=========
  116. ;;Shell
  117. (setq-default explicit-shell-file-name "/bin/bash")
  118. ;; =========
  119. ;; markdown
  120. (is-installed 'markdown-mode)
  121. (autoload 'markdown-mode "markdown-mode"
  122. "Major mode for editing Markdown files" t)
  123. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  124. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  125. (autoload 'gfm-mode "markdown-mode"
  126. "Major mode for editing GitHub Flavored Markdown files" t)
  127. (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
  128. ;; ========
  129. ;;Neotree
  130. (is-installed 'neotree)
  131. (require 'neotree)
  132. (global-set-key [f8] 'neotree-toggle)
  133. ;; ========
  134. ;; Python
  135. ;;=-=-=-=-=-=
  136. ;; Python completion:
  137. (is-installed 'anaconda-mode)
  138. (add-hook 'python-mode-hook 'anaconda-mode)
  139. (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  140. ;(add-hook 'python-mode-hook 'jedi:setup)
  141. ;(setq jedi:complete-on-dot t) ; optional
  142. ;(setq jedi:environment-root "/usr/local/bin/python3")
  143. ;;=======
  144. ;; Python pyvenv
  145. (is-installed 'pyvenv)
  146. (pyvenv-mode t)
  147. (setenv "WORKON_HOME" "~/.pyvenv/")
  148. ;(setq python-shell-interpreter (concat pyvenv-virtual-env "bin/python3"))
  149. ;(setq python-shell-interpreter "/usr/local/bin/python3")
  150. ;; -=-=-=-=-=-=-=-=-
  151. ;; My functions gmarx
  152. ;; Python chunk:
  153. (defun python-shell-send-chunk ()
  154. (interactive)
  155. (save-excursion
  156. (mark-paragraph)
  157. (let ((start (region-beginning))
  158. (end (region-end)))
  159. (python-shell-send-region start end))
  160. (keyboard-quit)))
  161. ;; my keybindings:
  162. (global-set-key (kbd "C-c C-k") 'python-shell-send-chunk)
  163. ;;====================
  164. ;; emacs startup config
  165. (setq inhibit-startup-message nil) ;;inhibit startup
  166. (global-visual-line-mode t)
  167. (tool-bar-mode -1)
  168. (menu-bar-mode -1)
  169. (global-hl-line-mode +1) ;; highlith current line
  170. (delete-selection-mode +1) ;; deletes selected text and replace it
  171. (scroll-bar-mode -1)
  172. (setq ns-right-alternate-modifier nil) ;; right option macos key enable
  173. (fset 'yes-or-no-p 'y-or-n-p) ;; Ask y/n instead of yes/no
  174. (add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; display line number when programming
  175. (show-paren-mode +1) ;; show matching parentheses
  176. ;;---------
  177. ;; 2.6 ace-window
  178. (is-installed 'ace-window)
  179. (global-set-key (kbd "M-o") 'ace-window)
  180. ;; 2.7 avy
  181. (is-installed 'avy)
  182. (avy-setup-default)
  183. (global-set-key (kbd "M-g f") 'avy-goto-line)
  184. ;; 2.8 multiple-cursors
  185. (is-installed 'multiple-cursors)
  186. (require 'multiple-cursors)
  187. (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
  188. (global-set-key (kbd "C->") 'mc/mark-next-like-this)
  189. (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
  190. (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
  191. (custom-set-variables
  192. ;; custom-set-variables was added by Custom.
  193. ;; If you edit it by hand, you could mess it up, so be careful.
  194. ;; Your init file should contain only one such instance.
  195. ;; If there is more than one, they won't work right.
  196. '(custom-safe-themes
  197. '("e19ac4ef0f028f503b1ccafa7c337021834ce0d1a2bca03fcebc1ef635776bea" "b0e446b48d03c5053af28908168262c3e5335dcad3317215d9fdeb8bac5bacf9" "4133d2d6553fe5af2ce3f24b7267af475b5e839069ba0e5c80416aa28913e89a" "fe2539ccf78f28c519541e37dc77115c6c7c2efcec18b970b16e4a4d2cd9891d" "4f1d2476c290eaa5d9ab9d13b60f2c0f1c8fa7703596fa91b235db7f99a9441b" default))
  198. '(package-selected-packages
  199. '(multiple-cursors ace-window which-key use-package pyvenv pdf-tools org-ref neotree markdown-mode jedi helm doom-themes doom-modeline docker-compose-mode auctex anaconda-mode)))
  200. (custom-set-faces
  201. ;; custom-set-faces was added by Custom.
  202. ;; If you edit it by hand, you could mess it up, so be careful.
  203. ;; Your init file should contain only one such instance.
  204. ;; If there is more than one, they won't work right.
  205. )