My emacs configuration
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.

494 lines
16 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. ;;; My basic configuration Gerardo Marx 15/Jul/2020
  2. ;;--------
  3. ;; Melpa repository:
  4. (require 'package)
  5. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  6. (package-initialize)
  7. ;; use-package
  8. (unless (package-installed-p 'use-package)
  9. (package-refresh-contents)
  10. (package-install 'use-package))
  11. ;; frame size
  12. (setq initial-frame-alist '((top . 10)(left . 20)
  13. (width . 90)(height . 50)))
  14. ;; which-key:
  15. (use-package which-key
  16. :ensure t
  17. :config (which-key-mode))
  18. ;; doom-themes
  19. (use-package doom-themes
  20. :ensure t
  21. :config
  22. (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
  23. doom-themes-enable-italic t) ; if nil, italics is universally disabled
  24. (load-theme ;'doom-one
  25. 'doom-tomorrow-day t)
  26. ;; Enable flashing mode-line on errors
  27. (doom-themes-visual-bell-config)
  28. ;; Enable custom neotree theme (all-the-icons must be installed!)
  29. (doom-themes-neotree-config)
  30. ;; or for treemacs users
  31. (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
  32. (doom-themes-treemacs-config)
  33. ;; Corrects (and improves) org-mode's native fontification.
  34. (doom-themes-org-config))
  35. ;; modeline
  36. (use-package doom-modeline
  37. :ensure t
  38. :init (doom-modeline-mode 1))
  39. ;; icons:
  40. (use-package all-the-icons
  41. :ensure t) ;; --> you need this M-x all-the-icons-install-fonts
  42. ;; startup config
  43. (setq inhibit-startup-message t) ;;inhibit startup
  44. (tool-bar-mode -1)
  45. (menu-bar-mode -1)
  46. (global-hl-line-mode +1) ;; highlith current line
  47. (delete-selection-mode +1) ;; deletes selected text and replace it
  48. (scroll-bar-mode -1)
  49. (setq ns-right-alternate-modifier nil) ;; right option macos key enable
  50. (setq backup-directory-alist '(("." . "~/.saves"))) ;; a backup dir to store no saved files
  51. (fset 'yes-or-no-p 'y-or-n-p) ;; Ask y/n instead of yes/no
  52. (add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; display line number when programming
  53. (show-paren-mode +1) ;; show matching parentheses
  54. ;; helm package:
  55. (use-package helm
  56. :ensure t
  57. :demand t
  58. :bind (("M-x" . helm-M-x)
  59. ("C-c h x" . helm-register) ; C-x r SPC and C-x r j
  60. ("C-c h g" . helm-google-suggest)
  61. ("C-c h M-:" . helm-eval-expression-with-eldoc)
  62. ("C-x C-f" . helm-find-files))
  63. :config
  64. (require 'helm-config)
  65. (helm-mode t))
  66. ;; projectile:
  67. (use-package projectile
  68. :ensure t
  69. :config
  70. (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
  71. (projectile-mode t))
  72. ;; helm-projectile:
  73. (use-package helm-projectile
  74. :after projectile
  75. :ensure t
  76. :init
  77. (require 'tramp)
  78. :config
  79. (helm-projectile-on))
  80. ;; temp:
  81. (setq ido-enable-flex-matching t)
  82. ;; dash-board:
  83. (use-package dashboard
  84. :ensure t
  85. :init
  86. (progn
  87. (setq recentf-exclude '("/Users/gmarx/beorg/"))
  88. (setq dashboard-items '(
  89. ;;(recents . 5)
  90. (bookmarks . 5)
  91. (projects . 5)
  92. (agenda . 5)))
  93. (setq dashboard-banner-logo-title "Welcome gMarx")
  94. (setq dashboard-set-file-icons t)
  95. (setq dashboard-set-init-info t)
  96. (setq dashboard-startup-banner 'logo)
  97. )
  98. :config
  99. (dashboard-setup-startup-hook))
  100. ;; treemacs
  101. (use-package treemacs
  102. :ensure t
  103. :init
  104. (with-eval-after-load 'winum
  105. (define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
  106. :config
  107. (progn
  108. (setq treemacs-is-never-other-window t)
  109. (setq treemacs-width 35))
  110. :bind
  111. (:map global-map
  112. ("M-0" . treemacs-select-window)
  113. ("C-x t t" . treemacs)))
  114. ;; treemacs-projectile
  115. (use-package treemacs-projectile
  116. :after treemacs projectile
  117. :ensure t)
  118. ;; magit
  119. (use-package magit
  120. :ensure t)
  121. ;; latex
  122. (use-package tex
  123. :defer t
  124. :ensure auctex
  125. :init
  126. (progn
  127. (setq-default TeX-master nil) ; Query for master file.
  128. (setq TeX-auto-save t) ; Enable parse on save.
  129. (setq TeX-save-query nil)
  130. (custom-set-variables '(LaTeX-command "latex -synctex=1"))
  131. ;;(setq TeX-command-force "LaTex")
  132. ;;(setq latex-run-command "pdflatex")
  133. (setq TeX-parse-self t) ; Enable parse on load.
  134. (setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin/"))
  135. (setq exec-path (append exec-path '("/Library/TeX/texbin/")))
  136. ;; pdf-tools configuration
  137. (setq TeX-PDF-mode t)
  138. (add-hook 'TeX-after-compilation-finished-functions
  139. #'TeX-revert-document-buffer)
  140. (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
  141. TeX-source-correlate-start-server t)
  142. (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo")
  143. (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  144. (add-hook 'pdf-view-mode-hook
  145. (lambda () (pdf-tools-enable-minor-modes)))
  146. )
  147. )
  148. ;; pdf-tools
  149. (use-package pdf-tools
  150. :ensure t
  151. :pin melpa
  152. :magic ("%PDF" . pdf-view-mode)
  153. :config
  154. (custom-set-variables
  155. '(pdf-tools-handle-upgrades nil))
  156. )
  157. ;;--------
  158. ;; latex-preview
  159. (use-package latex-preview-pane
  160. :ensure t)
  161. ;; latexmk
  162. (use-package auctex-latexmk
  163. :ensure t
  164. :init
  165. (auctex-latexmk-setup)
  166. :config
  167. (setq auctex-latexmk-inherit-TeX-PDF-mode t))
  168. ;;----------------------
  169. ;; flycheck
  170. (use-package flycheck
  171. :ensure t
  172. :init (global-flycheck-mode))
  173. ;; expand region
  174. (use-package expand-region
  175. :ensure t
  176. :bind
  177. ("C-=" . er/expand-region)
  178. ("C--" . er/contract-region))
  179. ;; org-bullets
  180. (use-package org-bullets
  181. :ensure t
  182. :init
  183. (setq org-support-shift-select t))
  184. ;; :hook
  185. ;; (org-mode . org-bullets-mode))
  186. ;;------pomodoro
  187. (use-package org-pomodoro
  188. :ensure t
  189. :after org
  190. :bind ("C-x p" . org-pomodoro))
  191. ;; org configuration:
  192. (add-hook 'org-mode-hook
  193. (lambda()
  194. ;; dictionary
  195. (org-bullets-mode 1)
  196. (ispell-change-dictionary "en")
  197. (setq org-image-actual-width nil)
  198. (setq org-tags-column 5)
  199. (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))
  200. (setq org-latex-create-formula-image-program 'imagemagick)
  201. (setq org-startup-indented t) ; Enable `org-indent-mode' by default
  202. (visual-line-mode 1)
  203. ))
  204. ;; Company-mode
  205. (use-package company
  206. :ensure t
  207. :init
  208. (add-hook 'after-init-hook 'global-company-mode))
  209. ;; ispell
  210. (dolist (hook '(org-mode-hook latex-mode-hook tex-mode-hook git-commit-mode-hook))
  211. (add-hook hook (lambda () (flyspell-mode 1))))
  212. ;;(setq ispell-dictionary "en")
  213. (setq ispell-program-name "/usr/local/bin/aspell")
  214. ;; Set default font:
  215. (add-to-list 'default-frame-alist
  216. '(font . "Source Code Pro-20"))
  217. ;; Activation org-agenda and capture
  218. (global-set-key (kbd "C-c l") 'org-store-link)
  219. (global-set-key (kbd "C-c a") 'org-agenda)
  220. (global-set-key (kbd "C-c c") 'org-capture)
  221. ;;++++++++++
  222. ;; sentence one space definition
  223. (setq sentence-end-double-space nil)
  224. ;;---------
  225. ;; Todo states for ORG:
  226. (setq org-todo-keywords
  227. (quote
  228. ((sequence "TODO(t)" "PROGRESS(g)" "PAUSE(p)" "CHECK(k)" "|" "DONE(d)" "CANCELED(c)"))))
  229. (setq org-todo-keyword-faces
  230. '(("PROGRESS" . "orange") ("PAUSE" . "magenta") ("CHECK" . "purple") ("CANCELED" . "red") ("DONE" . "green")))
  231. ;; capture:
  232. (setq org-capture-templates
  233. (quote (
  234. ("a" ; hotkey
  235. "Academia Todo" ; name
  236. entry ; type
  237. (file+headline "/Users/gmarx/beorg/academia.org" "Tasks") ;target
  238. "* TODO [#B] %^{Task}" ; template
  239. )
  240. ("t"
  241. "Task PhD"
  242. entry
  243. (file+datetree "~/beorg/phd.org")
  244. "* TODO [#A] %^{Task}")
  245. ("d"
  246. "Students"
  247. item
  248. (file+datetree "~/beorg/students.org")
  249. "- %U - %^{Activity}")
  250. ("r"
  251. "to Read"
  252. entry
  253. (file+headline "~/beorg/inbox.org" "to read")
  254. "* TODO %^{topic to read}\n%^{Why to read this?}"
  255. )
  256. ("s"
  257. "Schedule an event"
  258. entry
  259. (file+headline "~/beorg/inbox.org" "Scheduled events")
  260. "* %^{Event}\nSCHEDULED: %^t"
  261. )
  262. ("k"
  263. "Task inbox"
  264. entry
  265. (file+headline "~/beorg/inbox.org" "Tasks")
  266. "* TODO %^{Task} -> %^{move to}"
  267. )
  268. ("c"
  269. "Cheat-Sheet"
  270. entry
  271. (file+headline "~/beorg/cheatsheets.org" "Notes")
  272. "* %^{what solves}\n%^{the commands are}"
  273. )
  274. )))
  275. ;;-------end capture
  276. ;;=======
  277. ;;python
  278. (use-package virtualenvwrapper
  279. :ensure t
  280. :config
  281. (setq python-shell-interpreter "python3")
  282. (setq venv-location "~/.virtualenvs"))
  283. ;; org-alert
  284. (use-package org-alert
  285. :ensure t
  286. :config
  287. (setq alert-default-style 'osx-notifier))
  288. ;; reftex
  289. (use-package reftex
  290. :ensure t
  291. :defer t
  292. :config
  293. (setq reftex-cite-prompt-optional-args t)); Prompt for empty optional arguments in cite
  294. ;; org-exporter:
  295. (use-package ox-twbs
  296. :ensure t)
  297. ;;multiple coursors:
  298. (use-package ace-mc
  299. :ensure t
  300. :config
  301. (global-set-key (kbd "C-)") 'ace-mc-add-multiple-cursors)
  302. (global-set-key (kbd "C-M-)") 'ace-mc-add-single-cursor))
  303. ;;ace-jump:
  304. (use-package ace-jump-mode
  305. :ensure t
  306. :bind ("C-x j" . ace-jump-mode))
  307. ;; pyenv:
  308. (use-package pyvenv
  309. :ensure t
  310. :config
  311. (pyvenv-mode 1))
  312. ;;ess:
  313. ;(use-package ess
  314. ; :ensure t)
  315. ;(require 'ess-site)
  316. ;;-=-=-=-=-=-=-
  317. ;; mu4e
  318. (use-package mu4e
  319. :commands (mu4e)
  320. :init
  321. ;;(progn (require 'helm-mu))
  322. :config
  323. (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu/mu4e")
  324. (setq mu4e-mu-binary "/usr/local/bin/mu"))
  325. ;;-+-+-+-+-+-+-+-+-+-+-+-+
  326. ;; "default" parameters from Gmail
  327. (setq user-full-name "Gerardo Marx Chávez-Campos") ;;user
  328. (setq mu4e-compose-signature t) ;; signature in file ~/.signature
  329. (add-hook 'mu4e-compose-mode-hook 'flyspell-mode(setq ispell-local-dictionary "castellano")) ;; spell check
  330. ;; attempt to show images when viewing messages
  331. (setq mu4e-view-show-images t)
  332. (setq mu4e-sent-folder "/Gmail/sent"
  333. ;; mu4e-sent-messages-behavior 'delete ;; Unsure how this should be configured
  334. mu4e-drafts-folder "/Gmail/drafts"
  335. user-mail-address "gmarx_cc@itmorelia.edu.mx"
  336. smtpmail-local-domain "gmail.com"
  337. smtpmail-default-smtp-server "smtp.gmail.com"
  338. smtpmail-stream-type 'starttls
  339. smtpmail-smtp-server "smtp.gmail.com"
  340. smtpmail-smtp-service 587)
  341. ;; ---
  342. ;; Now I set a list of
  343. (defvar my-mu4e-account-alist
  344. '(("Gmail"
  345. (mu4e-sent-folder "/Gmail/sent")
  346. (mu4e-drafts-folder "/Gmail/drafts")
  347. (user-mail-address "gmarx_cc@itmorelia.edu.mx")
  348. (smtpmail-smtp-user "gmarx_cc@itmorelia.edu.mx")
  349. (smtpmail-local-domain "gmail.com")
  350. (smtpmail-default-smtp-server "smtp.gmail.com")
  351. (smtpmail-stream-type starttls)
  352. (smtpmail-smtp-server "smtp.gmail.com")
  353. (smtpmail-smtp-service 587)
  354. )
  355. ;; Include any other accounts here ...
  356. ("Exchange"
  357. (mu4e-sent-folder "/Exchange/sent")
  358. (mu4e-drafts-folder "/Exchange/drafts")
  359. (user-mail-address "gerardo.cc@morelia.tecnm.mx")
  360. (smtpmail-smtp-user "gerardo.cc@morelia.tecnm.mx")
  361. (smtpmail-local-domain "office365.com")
  362. (smtpmail-default-smtp-server "smtp.office365.com")
  363. (smtpmail-stream-type starttls)
  364. (smtpmail-smtp-server "smtp.office365.com")
  365. (smtpmail-smtp-service 587)
  366. )
  367. ;;
  368. ;; hotmail
  369. ("Hotmail"
  370. (mu4e-sent-folder "/Hotmail/sent")
  371. (mu4e-drafts-folder "/Hotmail/drafts")
  372. (user-mail-address "gmarx_cc@hotmail.com")
  373. (smtpmail-smtp-user "gmarx_cc@hotmail.com")
  374. (smtpmail-local-domain "office365.com")
  375. (smtpmail-default-smtp-server "smtp.office365.com")
  376. (smtpmail-stream-type starttls)
  377. (smtpmail-smtp-server "smtp.office365.com")
  378. (smtpmail-smtp-service 25)
  379. )
  380. ))
  381. ;; ---
  382. (defun my-mu4e-set-account ()
  383. "Set the account for composing a message.
  384. This function is taken from:
  385. https://www.djcbsoftware.nl/code/mu/mu4e/Multiple-accounts.html"
  386. (let* ((account
  387. (if mu4e-compose-parent-message
  388. (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir)))
  389. (string-match "/\\(.*?\\)/" maildir)
  390. (match-string 1 maildir))
  391. (completing-read (format "Compose with account: (%s) "
  392. (mapconcat #'(lambda (var) (car var))
  393. my-mu4e-account-alist "/"))
  394. (mapcar #'(lambda (var) (car var)) my-mu4e-account-alist)
  395. nil t nil nil (caar my-mu4e-account-alist))))
  396. (account-vars (cdr (assoc account my-mu4e-account-alist))))
  397. (if account-vars
  398. (mapc #'(lambda (var)
  399. (set (car var) (cadr var)))
  400. account-vars)
  401. (error "No email account found"))))
  402. (add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account)
  403. ;;-+-+-+-+-+-+-+-+-+-+-+-+
  404. ;;---------
  405. ;; mu4e-maildirs-extension
  406. (use-package mu4e-maildirs-extension
  407. :ensure t
  408. :init
  409. (mu4e-maildirs-extension)
  410. :custom
  411. (mu4e-maildirs-extension-custom-list '("/Gmail/INBOX" "/Exchange/INBOX" "/Hotmail/INBOX"))
  412. )
  413. ;; mu4e-alert
  414. (use-package mu4e-alert
  415. :ensure t
  416. :after mu4e
  417. :init
  418. (setq mu4e-alert-interesting-mail-query
  419. (concat
  420. "flag:unread maildir:/Exchange/INBOX "
  421. "OR "
  422. "flag:unread maildir:/Gmail/INBOX"
  423. ))
  424. (mu4e-alert-enable-mode-line-display)
  425. (defun gjstein-refresh-mu4e-alert-mode-line ()
  426. (interactive)
  427. (mu4e~proc-kill)
  428. (mu4e-alert-enable-mode-line-display)
  429. )
  430. (run-with-timer 0 60 'gjstein-refresh-mu4e-alert-mode-line))
  431. ;; helm
  432. (use-package helm-mu
  433. :ensure t
  434. :config
  435. ;;(define-key mu4e-main-mode-map "s" 'helm-mu)
  436. ;;(define-key mu4e-headers-mode-map "s" 'helm-mu)
  437. ;;(define-key mu4e-view-mode-map "s" 'helm-mu)
  438. )
  439. ;;agenda files
  440. ;;(setq org-agenda-files '("~/beorg/phd.org" "~/beorg/students.org" "~/beorg/inbox.org" "~/beorg/academia.org"))
  441. (setq recentf-exclude (org-agenda-files))
  442. (custom-set-variables
  443. ;; custom-set-variables was added by Custom.
  444. ;; If you edit it by hand, you could mess it up, so be careful.
  445. ;; Your init file should contain only one such instance.
  446. ;; If there is more than one, they won't work right.
  447. '(LaTeX-command "latex -synctex=1")
  448. '(custom-safe-themes
  449. (quote
  450. ("2f1518e906a8b60fac943d02ad415f1d8b3933a5a7f75e307e6e9a26ef5bf570" "71e5acf6053215f553036482f3340a5445aee364fb2e292c70d9175fb0cc8af7" "99ea831ca79a916f1bd789de366b639d09811501e8c092c85b2cb7d697777f93" "bf387180109d222aee6bb089db48ed38403a1e330c9ec69fe1f52460a8936b66" default)))
  451. '(org-agenda-files
  452. (quote
  453. ("~/beorg/inbox.org" "~/beorg/academia.org" "~/beorg/water-quality.org" "~/beorg/phd.org" "~/lwc/projects/dynamicSystems/dynamic-systems.org")))
  454. '(package-selected-packages
  455. (quote
  456. (pyvenv ess ace-mc ox-twbs org-alert latex-preview-pane org-pomodoro which-key virtualenvwrapper use-package treemacs-projectile pdf-tools org-bullets mu4e-maildirs-extension mu4e-alert magit helm-projectile helm-mu flycheck expand-region doom-themes doom-modeline dashboard company auctex)))
  457. '(pdf-tools-handle-upgrades nil)
  458. '(safe-local-variable-values
  459. (quote
  460. ((fill-column . 5000:)
  461. (ispell-local-dictionary . castellano)
  462. (ispell-local-directory . castellano)
  463. (LaTeX-includegraphics-read-file . LaTeX-includegraphics-read-file-relative)
  464. (set-fill-column . 5000)
  465. (set-fill-column . 2000)
  466. (TeX-auto-save . t)
  467. (TeX-parse-self . t)
  468. (org-attach-directory . "students/")
  469. (org-attach-use-inheritance . t)
  470. (org-attach-preferred-new-method . ask))))
  471. '(send-mail-function (quote smtpmail-send-it)))
  472. (custom-set-faces
  473. ;; custom-set-faces was added by Custom.
  474. ;; If you edit it by hand, you could mess it up, so be careful.
  475. ;; Your init file should contain only one such instance.
  476. ;; If there is more than one, they won't work right.
  477. '(org-document-title ((t (\,@headline (\,@ variable-tuple) :height 1.5 :underline nil))))
  478. '(org-level-1 ((t (\,@headline (\,@ variable-tuple) :height 1.25))))
  479. '(org-level-2 ((t (\,@headline (\,@ variable-tuple) :height 1.15))))
  480. '(org-level-3 ((t (\,@headline (\,@ variable-tuple) :height 1.12))))
  481. '(org-level-4 ((t (\,@headline (\,@ variable-tuple) :height 1.1))))
  482. '(org-level-5 ((t (\,@headline (\,@ variable-tuple)))))
  483. '(org-level-6 ((t (\,@headline (\,@ variable-tuple)))))
  484. '(org-level-7 ((t (\,@headline (\,@ variable-tuple)))))
  485. '(org-level-8 ((t (\,@headline (\,@ variable-tuple))))))