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.

234 lines
8.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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. ;;+++++++++++
  35. ;; Doom-themes, all-the-icons, mode-line and font
  36. (unless (package-installed-p 'doom-themes)
  37. (package-install 'doom-themes))
  38. (unless (package-installed-p 'all-the-icons)
  39. (package-install 'all-the-icons))
  40. (require 'doom-themes)
  41. ;; Global settings (defaults)
  42. (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
  43. doom-themes-enable-italic t) ; if nil, italics is universally disabled
  44. ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each
  45. ;; theme may have their own settings.
  46. (load-theme 'doom-one t)
  47. ;; Enable flashing mode-line on errors
  48. (doom-themes-visual-bell-config)
  49. ;; Enable custom neotree theme
  50. (doom-themes-neotree-config) ; all-the-icons fonts must be installed!
  51. ;; Installling doom-modeline:
  52. (unless (package-installed-p 'doom-modeline)
  53. (package-install 'doom-modeline))
  54. (require 'doom-modeline)
  55. (doom-modeline-mode 1)
  56. ;;Intalling all-the-icons font:
  57. (unless (package-installed-p 'all-the-icons)
  58. (package-install 'all-the-icons))
  59. ;; Set default font:
  60. (add-to-list 'default-frame-alist
  61. '(font . "Source Code Pro-13"))
  62. ;;+++++++
  63. ;;auctex:
  64. (is-installed 'auctex)
  65. (is-installed 'pdf-tools);; PDFtools
  66. (pdf-tools-install)
  67. (setenv "PATH" (concat "/Library/TeX/texbin:"
  68. (getenv "PATH")))
  69. (add-to-list 'exec-path "/Library/TeX/texbin")
  70. (setq TeX-auto-save t)
  71. (setq TeX-save-query nil)
  72. (setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
  73. (setq TeX-parse-self t)
  74. (setq-default TeX-master nil)
  75. (add-hook 'LaTeX-mode-hook 'visual-line-mode)
  76. (add-hook 'LaTeX-mode-hook 'flyspell-mode)
  77. (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
  78. (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
  79. (setq reftex-plug-into-AUCTeX t)
  80. (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
  81. TeX-source-correlate-start-server t)
  82. ;; Update PDF buffers after successful LaTeX runs
  83. (add-hook 'TeX-after-compilation-finished-functions
  84. #'TeX-revert-document-buffer)
  85. (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  86. (add-hook 'pdf-view-mode-hook
  87. (lambda () (pdf-tools-enable-minor-modes)))
  88. (add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
  89. (setq TeX-source-correlate-start-server t)
  90. ;(setq TeX-source-correlate-method 'synctex)
  91. ;;--end----
  92. ;;..............
  93. ;;========
  94. ;;Flyspell
  95. (setq ispell-program-name "/usr/bin/aspell")
  96. (dolist (hook '(text-mode-hook))
  97. (add-hook hook (lambda () (flyspell-mode 1))))
  98. ;; ==========
  99. ;; ORG files:
  100. (is-installed 'org-ref)
  101. (require 'org-ref)
  102. (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
  103. (setq org-latex-prefer-user-labels t)
  104. ;;; Crear gráficos con org-mode con ditaa y plantuml
  105. (setq org-plantuml-jar-path
  106. (expand-file-name "/opt/plantuml.jar"))
  107. (setq org-ditaa-jar-path "/usr/bin/ditaa")
  108. (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
  109. (latex . t)
  110. (python . t)
  111. ;; (shell . t)
  112. (ditaa . t)
  113. (plantuml . t)
  114. (ipython . t)
  115. ))
  116. ;; Syntax highlight in #+BEGIN_SRC blocks
  117. (setq org-src-fontify-natively t)
  118. ;; Don't prompt before running code in org
  119. (setq org-confirm-babel-evaluate nil)
  120. ;; Fix an incompatibility between the ob-async and ob-ipython packages
  121. (setq ob-async-no-async-languages-alist '("ipython"))
  122. (require 'ob-ipython)
  123. (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
  124. (is-installed 'org-bullets)
  125. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
  126. ;(setq org-ditaa-jar-path "/usr/bin/ditaa")
  127. ;(is-installed 'ditaa)
  128. ;; ==========
  129. ;; TRMAP
  130. (eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
  131. ;;=========
  132. ;;Shell
  133. (setq-default explicit-shell-file-name "/bin/bash")
  134. ;; =========
  135. ;; markdown
  136. (is-installed 'markdown-mode)
  137. (autoload 'markdown-mode "markdown-mode"
  138. "Major mode for editing Markdown files" t)
  139. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  140. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  141. (autoload 'gfm-mode "markdown-mode"
  142. "Major mode for editing GitHub Flavored Markdown files" t)
  143. (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
  144. ;; ========
  145. ;;Neotree
  146. (is-installed 'neotree)
  147. (require 'neotree)
  148. (global-set-key [f8] 'neotree-toggle)
  149. ;;=======
  150. ;; Python completion:
  151. (is-installed 'anaconda-mode)
  152. (add-hook 'python-mode-hook 'anaconda-mode)
  153. (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  154. (is-installed 'elpy)
  155. (elpy-enable)
  156. ;(add-hook 'python-mode-hook 'jedi:setup)
  157. ;(setq jedi:complete-on-dot t) ; optional
  158. ;(setq jedi:environment-root "/usr/local/bin/python3")
  159. ;;=======
  160. ;; Python pyvenv
  161. (is-installed 'pyvenv)
  162. (pyvenv-mode t)
  163. (setenv "WORKON_HOME" "~/.pyvenv/")
  164. ;;(setq python-shell-interpreter (concat pyvenv-virtual-env "bin/python3")) ;;(setq python-shell-interpreter "/usr/local/bin/python3")
  165. ;;-+-+-+-+-+-+-+-+-+-
  166. ;; My functions gmarx
  167. ;; Python chunk:
  168. (defun python-shell-send-chunk ()
  169. "Eval a region on python console"
  170. (interactive)
  171. (save-excursion
  172. (mark-paragraph)
  173. (let ((start (region-beginning))
  174. (end (region-end)))
  175. (python-shell-send-region start end))
  176. (keyboard-quit)))
  177. ;; my keybindings:
  178. ;; requires that only be active on the pytho-hook
  179. (global-set-key (kbd "C-.") 'python-shell-send-chunk)
  180. (global-set-key (kbd "C-,") 'python-shell-send-statement)
  181. ;;====================
  182. ;; emacs startup config
  183. (setq inhibit-startup-message t) ;;inhibit startup
  184. (global-visual-line-mode t)
  185. (tool-bar-mode -1)
  186. (menu-bar-mode -1)
  187. (global-hl-line-mode +1) ;; highlith current line
  188. (delete-selection-mode +1) ;; deletes selected text and replace it
  189. (scroll-bar-mode -1)
  190. (setq ns-right-alternate-modifier nil) ;; right option macos key enable
  191. (fset 'yes-or-no-p 'y-or-n-p) ;; Ask y/n instead of yes/no
  192. (add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; display line number when programming
  193. (show-paren-mode +1) ;; show matching parentheses
  194. ;; 2.6 ace-window
  195. (is-installed 'ace-window)
  196. (global-set-key (kbd "M-o") 'ace-window)
  197. ;; 2.7 avy
  198. (is-installed 'avy)
  199. (avy-setup-default)
  200. (global-set-key (kbd "M-g f") 'avy-goto-line)
  201. ;; 2.8 multiple-cursors
  202. (is-installed 'multiple-cursors)
  203. (require 'multiple-cursors)
  204. (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
  205. (global-set-key (kbd "C->") 'mc/mark-next-like-this)
  206. (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
  207. (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
  208. ;;---------
  209. (custom-set-variables
  210. ;; custom-set-variables was added by Custom.
  211. ;; If you edit it by hand, you could mess it up, so be careful.
  212. ;; Your init file should contain only one such instance.
  213. ;; If there is more than one, they won't work right.
  214. '(custom-safe-themes
  215. '("613aedadd3b9e2554f39afe760708fc3285bf594f6447822dd29f947f0775d6c" "b0e446b48d03c5053af28908168262c3e5335dcad3317215d9fdeb8bac5bacf9" "e19ac4ef0f028f503b1ccafa7c337021834ce0d1a2bca03fcebc1ef635776bea" "d268b67e0935b9ebc427cad88ded41e875abfcc27abd409726a92e55459e0d01" "745d03d647c4b118f671c49214420639cb3af7152e81f132478ed1c649d4597d" "246a9596178bb806c5f41e5b571546bb6e0f4bd41a9da0df5dfbca7ec6e2250c" "4f1d2476c290eaa5d9ab9d13b60f2c0f1c8fa7703596fa91b235db7f99a9441b" default))
  216. '(package-selected-packages
  217. '(org-bullets multiple-cursors ace-window ipython-shell-send ob-ipython elpy ditaa pyvenv anaconda-mode which-key use-package org-ref neotree markdown-mode doom-themes doom-modeline auctex))
  218. '(safe-local-variable-values
  219. '((TeX-auto-save . t)
  220. (TeX-parse-self . t)
  221. (org-attach-use-inheritance . t)
  222. (LaTeX-includegraphics-read-file . LaTeX-includegraphics-read-file-relative))))
  223. (custom-set-faces
  224. ;; custom-set-faces was added by Custom.
  225. ;; If you edit it by hand, you could mess it up, so be careful.
  226. ;; Your init file should contain only one such instance.
  227. ;; If there is more than one, they won't work right.
  228. )