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.

292 lines
11 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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 . 35)(left . 10)
  33. (width . 80)(height . 45)))
  34. ;; Opacity
  35. (set-frame-parameter (selected-frame) 'alpha '(85 . 50))
  36. (add-to-list 'default-frame-alist '(alpha . (90 . 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-18"))
  65. ;;+++++++
  66. ;;auctex:
  67. (is-installed 'auctex)
  68. (setenv "PATH" (concat "/Library/TeX/texbin:"
  69. (getenv "PATH")))
  70. (add-to-list 'exec-path "/Library/TeX/texbin")
  71. (setq TeX-auto-save t)
  72. (setq TeX-save-query nil)
  73. (setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
  74. (setq TeX-parse-self t)
  75. (setq-default TeX-master nil)
  76. (add-hook 'LaTeX-mode-hook 'visual-line-mode)
  77. (add-hook 'LaTeX-mode-hook 'flyspell-mode)
  78. (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
  79. (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
  80. ;;Use brew upgrade pdf-tools instead.
  81. (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo")
  82. (pdf-tools-install)
  83. (setq reftex-plug-into-AUCTeX t)
  84. (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
  85. TeX-source-correlate-start-server t)
  86. ;; Update PDF buffers after successful LaTeX runs
  87. (add-hook 'TeX-after-compilation-finished-functions
  88. #'TeX-revert-document-buffer)
  89. (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  90. (add-hook 'pdf-view-mode-hook
  91. (lambda () (pdf-tools-enable-minor-modes)))
  92. (setq TeX-source-correlate-method 'synctex)
  93. ;;--end----
  94. ;;++++++++
  95. ;; emacs startup config
  96. (setq inhibit-startup-message t) ;;inhibit startup
  97. (global-visual-line-mode t)
  98. (tool-bar-mode -1)
  99. (menu-bar-mode -1)
  100. (global-hl-line-mode +1) ;; highlith current line
  101. (delete-selection-mode +1) ;; deletes selected text and replace it
  102. (scroll-bar-mode -1)
  103. (setq ns-right-alternate-modifier nil) ;; right option macos key enable
  104. (fset 'yes-or-no-p 'y-or-n-p) ;; Ask y/n instead of yes/no
  105. (add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; display line number when programming
  106. (show-paren-mode +1) ;; show matching parentheses
  107. ;;---------
  108. ;;Dashboard
  109. (is-installed 'dashboard)
  110. (require 'dashboard)
  111. (dashboard-setup-startup-hook)
  112. ;; Set the title
  113. (setq dashboard-banner-logo-title "Welcome to Emacs Marx")
  114. ;; Set the banner
  115. (setq dashboard-startup-banner 'logo)
  116. ;; Value can be
  117. ;; 'official which displays the official emacs logo
  118. ;; 'logo which displays an alternative emacs logo
  119. ;; 1, 2 or 3 which displays one of the text banners
  120. ;; "path/to/your/image.gif", "path/to/your/image.png" or "path/to/your/text.txt" which displays whatever gif/image/text you would prefer
  121. ;; Content is not centered by default. To center, set
  122. (setq dashboard-center-content nil)
  123. ;; To disable shortcut "jump" indicators for each section, set
  124. (setq dashboard-show-shortcuts nil)
  125. (setq dashboard-items '((recents . 5)
  126. (bookmarks . 5)
  127. (projects . 5)
  128. (agenda . 5)
  129. (registers . 5)))
  130. ;;========
  131. ;;Flyspell
  132. (setq ispell-program-name "/usr/local/bin/aspell")
  133. ;(setq ispell-aspell-data-dir "/usr/local/Cellar/ispell/3.4.04/lib/ispell/")
  134. ;(setq ispell-aspell-dict-dir ispell-aspell-data-dir)
  135. (dolist (hook '(text-mode-hook))
  136. (add-hook hook (lambda () (flyspell-mode 1))))
  137. ;; ==========
  138. ;; ORG files:
  139. (is-installed 'org-ref)
  140. (is-installed 'org-ref)
  141. (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
  142. (setq org-latex-prefer-user-labels t)
  143. (is-installed 'org-bullets)
  144. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
  145. ;;(plist-put org-format-latex-options :scale 1.5)
  146. ;;(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
  147. ; inline images
  148. ;;(setq org-image-actual-width nil)
  149. (setq shr-max-image-proportion 0.5)
  150. ; source blocks no confirmation to run
  151. (setq org-confirm-babel-evaluate nil)
  152. ;; languages for source blocks
  153. (org-babel-do-load-languages
  154. 'org-babel-load-languages
  155. '((emacs-lisp . t)
  156. (shell . t) ; in my case /bin/bash
  157. ; (scheme . t)
  158. (python . t)
  159. ; (ledger . t)
  160. ; (sed . t)
  161. ; (awk . t)
  162. ; (clojure . t)
  163. ))
  164. ;;keybindings in org-mode
  165. (define-key org-mode-map (kbd "C-<tab>") 'completion-at-point)
  166. ;; ==========
  167. ;; TRMAP
  168. (eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
  169. ;;=========
  170. ;;Shell
  171. (setq-default explicit-shell-file-name "/bin/bash")
  172. (define-key shell-mode-map (kbd "<tab>") 'completion-at-point)
  173. ;; =========
  174. ;; markdown
  175. (is-installed 'markdown-mode)
  176. (autoload 'markdown-mode "markdown-mode"
  177. "Major mode for editing Markdown files" t)
  178. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  179. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  180. (autoload 'gfm-mode "markdown-mode"
  181. "Major mode for editing GitHub Flavored Markdown files" t)
  182. (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
  183. ;; ========
  184. ;; docker
  185. (is-installed 'docker-compose-mode)
  186. (require 'docker-compose-mode)
  187. ;;========
  188. ;;Neotree
  189. (is-installed 'neotree)
  190. (require 'neotree)
  191. (global-set-key [f8] 'neotree-toggle)
  192. ;;========
  193. ;; auto-complete
  194. (is-installed 'auto-complete)
  195. (ac-config-default)
  196. ;;=======
  197. ;; Python completion:
  198. (is-installed 'corfu)
  199. (corfu-global-mode t)
  200. ;;=======
  201. ;; Python pyvenv
  202. (is-installed 'pyvenv)
  203. (pyvenv-mode t)
  204. (setenv "WORKON_HOME" "~/.pyvenv/")
  205. ;(setq python-shell-interpreter (concat pyvenv-virtual-env "bin/python3"))
  206. ;(setq python-shell-interpreter "/usr/local/bin/python3")
  207. ;;--------
  208. ;;ace-windows:
  209. (is-installed 'ace-window)
  210. (global-set-key (kbd "M-o") 'ace-window)
  211. ;;--------
  212. ;;avy
  213. (is-installed 'avy)
  214. (global-set-key (kbd "C-:") 'avy-goto-char)
  215. (global-set-key (kbd "M-l") 'avy-goto-line)
  216. (global-set-key (kbd "C-'") 'avy-goto-char-2)
  217. (global-set-key (kbd "M-g w") 'avy-goto-word-1)
  218. ;;--------
  219. ;;multiple-cursors
  220. (is-installed 'multiple-cursors)
  221. (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
  222. (global-set-key (kbd "C->") 'mc/mark-next-like-this)
  223. (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
  224. (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
  225. ;;-=-=-=-=-=-=-=
  226. (is-installed 'browse-kill-ring)
  227. (require 'browse-kill-ring)
  228. (browse-kill-ring-default-keybindings)
  229. ;;+0+0+0+0+0+0+
  230. ;; MacOS only:
  231. (is-installed 'osx-dictionary)
  232. (global-set-key (kbd "C-c d") 'osx-dictionary-search-word-at-point) ;; Key bindings
  233. ;;+0+0+0+0+0+0+0+
  234. ;;-+-+-+-+-+-+-+-
  235. ;; My functions gmarx:
  236. (defun python-shell-send-chunk ()
  237. (interactive)
  238. (save-excursion
  239. (mark-paragraph)
  240. (let ((start (region-beginning))
  241. (end (region-end)))
  242. (python-shell-send-region start end))
  243. (keyboard-quit)))
  244. ;; my keybindings:
  245. (global-set-key (kbd "C-c C-k") 'python-shell-send-chunk)
  246. ;;Pomodoro
  247. ;;(is-installed 'org-pomodoro)
  248. ;;(pomodoro-add-to-mode-line)
  249. ;;==========
  250. (custom-set-variables
  251. ;; custom-set-variables was added by Custom.
  252. ;; If you edit it by hand, you could mess it up, so be careful.
  253. ;; Your init file should contain only one such instance.
  254. ;; If there is more than one, they won't work right.
  255. '(LaTeX-command "latex -synctex=1")
  256. '(custom-safe-themes
  257. '("4bca89c1004e24981c840d3a32755bf859a6910c65b829d9441814000cf6c3d0" "f2927d7d87e8207fa9a0a003c0f222d45c948845de162c885bf6ad2a255babfd" "8f5a7a9a3c510ef9cbb88e600c0b4c53cdcdb502cfe3eb50040b7e13c6f4e78e" "d74c5485d42ca4b7f3092e50db687600d0e16006d8fa335c69cf4f379dbd0eee" "5b809c3eae60da2af8a8cfba4e9e04b4d608cb49584cb5998f6e4a1c87c057c4" "0fe24de6d37ea5a7724c56f0bb01efcbb3fe999a6e461ec1392f3c3b105cc5ac" "aaa4c36ce00e572784d424554dcc9641c82d1155370770e231e10c649b59a074" "08a27c4cde8fcbb2869d71fdc9fa47ab7e4d31c27d40d59bf05729c4640ce834" "f4876796ef5ee9c82b125a096a590c9891cec31320569fc6ff602ff99ed73dca" "7a994c16aa550678846e82edc8c9d6a7d39cc6564baaaacc305a3fdc0bd8725f" "c4bdbbd52c8e07112d1bfd00fee22bf0f25e727e95623ecb20c4fa098b74c1bd" "e074be1c799b509f52870ee596a5977b519f6d269455b84ed998666cf6fc802a" "4a8d4375d90a7051115db94ed40e9abb2c0766e80e228ecad60e06b3b397acab" "75b8719c741c6d7afa290e0bb394d809f0cc62045b93e1d66cd646907f8e6d43" "e3c64e88fec56f86b49dcdc5a831e96782baf14b09397d4057156b17062a8848" default))
  258. '(org-agenda-files
  259. '("~/ownCloud/projects/iProjects.org" "~/ownCloud/projects/postdoctorado/postdoctorado.org" "~/ownCloud/projects/phd/phd.org" "~/ownCloud/org/linux.org" "~/ownCloud/org/iDesiIng.org"))
  260. '(package-selected-packages
  261. '(browse-kill-ring dashboard org-bullets org-pomodoro pomodoro corfu company-anaconda company-jedi anaconda-mode which-key use-package pyvenv pkg-info org-ref neotree markdown-mode jedi helm-projectile doom-themes doom-modeline docker-compose-mode auctex))
  262. '(pdf-tools-handle-upgrades nil)
  263. '(safe-local-variable-values
  264. '((org-attach-preferred-new-method . ask)
  265. (display-line-numbers . t)
  266. (LaTeX-includegraphics-read-file . LaTeX-includegraphics-read-file-relative)
  267. (org-attach-use-inheritance . t)
  268. (org-attach-id-dir . /Users/gmarx/ownCLoud/org/phd/)
  269. (org-attach-id-dir . /Users/gmarx/ownCloud/org/phd/)
  270. (org-startup-folded . "fold")
  271. (org-startup-folded . fold)
  272. (org-startup-folded . t)
  273. (gnus-group-uncollapsed-levels)
  274. (gnus-group-uncollapsed-levels . t)
  275. (org-todo-keywords
  276. (sequence "Marx" "Luis" "Pascual" "Osvaldo" "DONE"))
  277. (org-todo-keywords
  278. (sequence "Marx" "Luis" "Pascual" "Osvaldo" | "DONE"))
  279. (org-todo-keywords
  280. (type "Marx" "Luis" "Pascual" "Osvaldo" | "DONE"))
  281. (org-todo-keywords quote
  282. ((type "Marx" "Luis" "Pascual" "Osvaldo" | "DONE"))))))
  283. (custom-set-faces
  284. ;; custom-set-faces was added by Custom.
  285. ;; If you edit it by hand, you could mess it up, so be careful.
  286. ;; Your init file should contain only one such instance.
  287. ;; If there is more than one, they won't work right.
  288. )