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.

194 lines
6.8 KiB

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-15"))
  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. (defun framesMenus-display-buffer-use-some-frame (fun &rest args)
  84. "Use `display-buffer-use-some-frame' as `display-buffer-overriding-action'.
  85. Then run FUN with ARGS."
  86. (let ((display-buffer-overriding-action '(display-buffer-use-some-frame)))
  87. (apply fun args)))
  88. (advice-add 'TeX-pdf-tools-sync-view :around #'framesMenus-display-buffer-use-some-frame)
  89. (advice-add 'pdf-sync-backward-search-mouse :around #'framesMenus-display-buffer-use-some-frame)
  90. (add-hook 'TeX-after-compilation-finished-functions
  91. #'TeX-revert-document-buffer)
  92. (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  93. (add-hook 'pdf-view-mode-hook
  94. (lambda () (pdf-tools-enable-minor-modes)))
  95. (setq TeX-source-correlate-method 'synctex)
  96. ;;--end----
  97. ;;..............
  98. ;;========
  99. ;;Flyspell
  100. (setq ispell-program-name "/usr/bin/aspell")
  101. (dolist (hook '(text-mode-hook))
  102. (add-hook hook (lambda () (flyspell-mode 1))))
  103. ;; ==========
  104. ;; ORG files:
  105. (is-installed 'org-ref)
  106. (require 'org-ref)
  107. (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
  108. (setq org-latex-prefer-user-labels t)
  109. ;; ==========
  110. ;; TRMAP
  111. (eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
  112. ;;=========
  113. ;;Shell
  114. (setq-default explicit-shell-file-name "/bin/bash")
  115. ;; =========
  116. ;; markdown
  117. (is-installed 'markdown-mode)
  118. (autoload 'markdown-mode "markdown-mode"
  119. "Major mode for editing Markdown files" t)
  120. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  121. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  122. (autoload 'gfm-mode "markdown-mode"
  123. "Major mode for editing GitHub Flavored Markdown files" t)
  124. (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
  125. ;; ========
  126. ;;Neotree
  127. (is-installed 'neotree)
  128. (require 'neotree)
  129. (global-set-key [f8] 'neotree-toggle)
  130. ;; ========
  131. ;; Python
  132. ;;=-=-=-=-=-=
  133. ;; Python completion:
  134. (is-installed 'anaconda-mode)
  135. (add-hook 'python-mode-hook 'anaconda-mode)
  136. (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  137. ;(add-hook 'python-mode-hook 'jedi:setup)
  138. ;(setq jedi:complete-on-dot t) ; optional
  139. ;(setq jedi:environment-root "/usr/local/bin/python3")
  140. ;;=======
  141. ;; Python pyvenv
  142. (is-installed 'pyvenv)
  143. (pyvenv-mode t)
  144. (setenv "WORKON_HOME" "~/.pyvenv/")
  145. ;(setq python-shell-interpreter (concat pyvenv-virtual-env "bin/python3"))
  146. ;(setq python-shell-interpreter "/usr/local/bin/python3")
  147. ;; -=-=-=-=-=-=-=-=-
  148. ;; My functions gmarx
  149. ;; Python chunk:
  150. (defun python-shell-send-chunk ()
  151. (interactive)
  152. (save-excursion
  153. (mark-paragraph)
  154. (let ((start (region-beginning))
  155. (end (region-end)))
  156. (python-shell-send-region start end))
  157. (keyboard-quit)))
  158. ;; my keybindings:
  159. (global-set-key (kbd "C-c C-k") 'python-shell-send-chunk)
  160. ;;====================
  161. ;; emacs startup config
  162. (setq inhibit-startup-message nil) ;;inhibit startup
  163. (global-visual-line-mode t)
  164. (tool-bar-mode -1)
  165. (menu-bar-mode -1)
  166. (global-hl-line-mode +1) ;; highlith current line
  167. (delete-selection-mode +1) ;; deletes selected text and replace it
  168. (scroll-bar-mode -1)
  169. (setq ns-right-alternate-modifier nil) ;; right option macos key enable
  170. (fset 'yes-or-no-p 'y-or-n-p) ;; Ask y/n instead of yes/no
  171. (add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; display line number when programming
  172. (show-paren-mode +1) ;; show matching parentheses
  173. ;;---------
  174. (custom-set-variables
  175. ;; custom-set-variables was added by Custom.
  176. ;; If you edit it by hand, you could mess it up, so be careful.
  177. ;; Your init file should contain only one such instance.
  178. ;; If there is more than one, they won't work right.
  179. '(custom-safe-themes
  180. '("b0e446b48d03c5053af28908168262c3e5335dcad3317215d9fdeb8bac5bacf9" default))
  181. '(package-selected-packages
  182. '(anaconda-mode which-key use-package pyvenv pdf-tools org-ref neotree markdown-mode jedi helm doom-themes doom-modeline docker-compose-mode auctex))
  183. '(safe-local-variable-values
  184. '((LaTeX-includegraphics-read-file . LaTeX-includegraphics-read-file-relative))))
  185. (custom-set-faces
  186. ;; custom-set-faces was added by Custom.
  187. ;; If you edit it by hand, you could mess it up, so be careful.
  188. ;; Your init file should contain only one such instance.
  189. ;; If there is more than one, they won't work right.
  190. )