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.

428 lines
14 KiB

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. :ensure t
  75. :init
  76. (progn
  77. (require 'tramp)
  78. )
  79. :config (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 dashboard-items '((recents . 5)
  88. (bookmarks . 5)
  89. (projects . 5)
  90. (agenda . 5)))
  91. (setq dashboard-banner-logo-title "Welcome gMarx")
  92. (setq dashboard-set-file-icons t)
  93. (setq dashboard-set-init-info t)
  94. (setq dashboard-startup-banner 'logo)
  95. )
  96. :config
  97. (dashboard-setup-startup-hook))
  98. ;; treemacs
  99. (use-package treemacs
  100. :ensure t
  101. :init
  102. (with-eval-after-load 'winum
  103. (define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
  104. :config
  105. (progn
  106. (setq treemacs-is-never-other-window t)
  107. (setq treemacs-width 35))
  108. :bind
  109. (:map global-map
  110. ("M-0" . treemacs-select-window)
  111. ("C-x t t" . treemacs)))
  112. ;; treemacs-projectile
  113. (use-package treemacs-projectile
  114. :after treemacs projectile
  115. :ensure t)
  116. ;; magit
  117. (use-package magit
  118. :ensure t)
  119. ;; latex
  120. (use-package tex
  121. :defer t
  122. :ensure auctex
  123. :config
  124. (setq TeX-auto-save t)
  125. (setq latex-run-command "pdflatex")
  126. (setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin/"))
  127. (setq exec-path (append exec-path '("/Library/TeX/texbin/")))
  128. )
  129. ;; Use pdf-tools to open PDF files
  130. (use-package pdf-tools
  131. :load-path "site-lisp/pdf-tools/lisp"
  132. :magic ("%PDF" . pdf-view-mode)
  133. :config
  134. (pdf-tools-install :no-query)
  135. :init
  136. (add-hook 'TeX-after-compilation-finished-functions
  137. #'TeX-revert-document-buffer)
  138. (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo")
  139. (setq TeX-view-program-selection '((output-pdf "PDF Tools")))
  140. ;; (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  141. )
  142. ;; (use-package pdf-tools
  143. ;; :ensure nil
  144. ;; :pin melpa
  145. ;; :config
  146. ;; (custom-set-variables
  147. ;; '(pdf-tools-handle-upgrades nil)) ; Use brew upgrade pdf-tools instead.
  148. ;; (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo"))
  149. ;; ;;-----------------------
  150. ;; ;; Use pdf-tools to open PDF files
  151. ;; (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
  152. ;; TeX-source-correlate-start-server t)
  153. ;;(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  154. ;; ;; Update PDF buffers after successful LaTeX runs
  155. ;; (add-hook 'TeX-after-compilation-finished-functions
  156. ;; #'TeX-revert-document-buffer)
  157. ;;----------------------
  158. ;; flycheck
  159. (use-package flycheck
  160. :ensure t
  161. :init (global-flycheck-mode))
  162. ;; expand region
  163. (use-package expand-region
  164. :ensure t
  165. :bind
  166. ("C-=" . er/expand-region)
  167. ("C--" . er/contract-region))
  168. ;; org-bullets
  169. (use-package org-bullets
  170. :ensure t
  171. :init
  172. (setq org-support-shift-select t))
  173. ;; :hook
  174. ;; (org-mode . org-bullets-mode))
  175. ;; org configuration:
  176. (setq org-agenda-files '("~/beorg/phd.org" "~/beorg/students.org" "~/beorg/inbox.org" "~/beorg/academia.org"))
  177. (add-hook 'org-mode-hook
  178. (lambda()
  179. ;; dictionary
  180. (org-bullets-mode 1)
  181. (ispell-change-dictionary "en")
  182. (setq org-image-actual-width nil)
  183. (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))
  184. (setq org-latex-create-formula-image-program 'imagemagick)
  185. (setq org-startup-indented t) ; Enable `org-indent-mode' by default
  186. (visual-line-mode 1)
  187. ))
  188. ;; Company-mode
  189. (use-package company
  190. :ensure t
  191. :init
  192. (add-hook 'after-init-hook 'global-company-mode))
  193. ;; ispell
  194. (dolist (hook '(org-mode-hook latex-mode-hook tex-mode-hook git-commit-mode-hook))
  195. (add-hook hook (lambda () (flyspell-mode 1))))
  196. ;;(setq ispell-dictionary "en")
  197. (setq ispell-program-name "/usr/local/bin/aspell")
  198. ;; Set default font:
  199. (add-to-list 'default-frame-alist
  200. '(font . "Source Code Pro-20"))
  201. ;; Activation org-agenda and capture
  202. (global-set-key (kbd "C-c l") 'org-store-link)
  203. (global-set-key (kbd "C-c a") 'org-agenda)
  204. (global-set-key (kbd "C-c c") 'org-capture)
  205. ;;++++++++++
  206. ;; sentence one space definition
  207. (setq sentence-end-double-space nil)
  208. ;;---------
  209. ;; Todo states for ORG:
  210. (setq org-todo-keywords
  211. (quote
  212. ((sequence "TODO(t)" "PROGRESS(g)" "PAUSE(p)" "CHECK(k)" "|" "DONE(d)" "CANCELED(c)"))))
  213. (setq org-todo-keyword-faces
  214. '(("PROGRESS" . "orange") ("PAUSE" . "magenta") ("CHECK" . "purple") ("CANCELED" . "red") ("DONE" . "green")))
  215. ;; capture:
  216. (setq org-capture-templates
  217. (quote (
  218. ("a" ; hotkey
  219. "Academia Todo" ; name
  220. entry ; type
  221. (file+headline "/Users/gmarx/beorg/academia.org" "Tasks") ;target
  222. "* TODO [#B] %^{Task}" ; template
  223. )
  224. ("t"
  225. "Task PhD"
  226. entry
  227. (file+datetree "~/beorg/phd.org")
  228. "* TODO [#A] %^{Task}")
  229. ("d"
  230. "Students"
  231. item
  232. (file+datetree "~/beorg/students.org")
  233. "- %U - %^{Activity}")
  234. ("r"
  235. "to Read"
  236. entry
  237. (file+headline "~/beorg/inbox.org" "to read")
  238. "* TODO %^{topic to read}\n%^{Why to read this?}"
  239. )
  240. ("s"
  241. "Schedule an event"
  242. entry
  243. (file+headline "~/beorg/inbox.org" "Scheduled events")
  244. "* %^{Event}\nSCHEDULED: %^t"
  245. )
  246. ("k"
  247. "Task inbox"
  248. entry
  249. (file+headline "~/beorg/inbox.org" "Tasks")
  250. "* TODO %^{Task} -> %^{move to}"
  251. )
  252. ("c"
  253. "Cheat-Sheet"
  254. entry
  255. (file+headline "~/beorg/cheatsheets.org" "Notes")
  256. "* %^{what solves}\n%^{the commands are}"
  257. )
  258. )))
  259. ;;-------end capture
  260. ;;=======
  261. ;;python
  262. (use-package virtualenvwrapper
  263. :ensure t
  264. :config
  265. (setq python-shell-interpreter "python3")
  266. (setq venv-location "~/.virtualenvs"))
  267. ;; mu4e
  268. (use-package mu4e
  269. :commands (mu4e)
  270. :init
  271. ;;(progn (require 'helm-mu))
  272. :config
  273. (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu/mu4e")
  274. (setq mu4e-mu-binary "/usr/local/bin/mu"))
  275. ;;-+-+-+-+-+-+-+-+-+-+-+-+
  276. ;; "default" parameters from Gmail
  277. (setq user-full-name "Gerardo Marx Chávez-Campos") ;;user
  278. (setq mu4e-compose-signature t) ;; signature in file ~/.signature
  279. (add-hook 'mu4e-compose-mode-hook 'flyspell-mode(setq ispell-local-dictionary "castellano")) ;; spell check
  280. ;; attempt to show images when viewing messages
  281. (setq mu4e-view-show-images t)
  282. (setq mu4e-sent-folder "/Gmail/sent"
  283. ;; mu4e-sent-messages-behavior 'delete ;; Unsure how this should be configured
  284. mu4e-drafts-folder "/Gmail/drafts"
  285. user-mail-address "gmarx_cc@itmorelia.edu.mx"
  286. smtpmail-local-domain "gmail.com"
  287. smtpmail-default-smtp-server "smtp.gmail.com"
  288. smtpmail-stream-type 'starttls
  289. smtpmail-smtp-server "smtp.gmail.com"
  290. smtpmail-smtp-service 587)
  291. ;; ---
  292. ;; Now I set a list of
  293. (defvar my-mu4e-account-alist
  294. '(("Gmail"
  295. (mu4e-sent-folder "/Gmail/sent")
  296. (mu4e-drafts-folder "/Gmail/drafts")
  297. (user-mail-address "gmarx_cc@itmorelia.edu.mx")
  298. (smtpmail-smtp-user "gmarx_cc@itmorelia.edu.mx")
  299. (smtpmail-local-domain "gmail.com")
  300. (smtpmail-default-smtp-server "smtp.gmail.com")
  301. (smtpmail-stream-type starttls)
  302. (smtpmail-smtp-server "smtp.gmail.com")
  303. (smtpmail-smtp-service 587)
  304. )
  305. ;; Include any other accounts here ...
  306. ("Exchange"
  307. (mu4e-sent-folder "/Exchange/sent")
  308. (mu4e-drafts-folder "/Exchange/drafts")
  309. (user-mail-address "gerardo.cc@morelia.tecnm.mx")
  310. (smtpmail-smtp-user "gerardo.cc@morelia.tecnm.mx")
  311. (smtpmail-local-domain "office365.com")
  312. (smtpmail-default-smtp-server "smtp.office365.com")
  313. (smtpmail-stream-type starttls)
  314. (smtpmail-smtp-server "smtp.office365.com")
  315. (smtpmail-smtp-service 587)
  316. )
  317. ;;
  318. ;; hotmail
  319. ("Hotmail"
  320. (mu4e-sent-folder "/Hotmail/sent")
  321. (mu4e-drafts-folder "/Hotmail/drafts")
  322. (user-mail-address "gmarx_cc@hotmail.com")
  323. (smtpmail-smtp-user "gmarx_cc@hotmail.com")
  324. (smtpmail-local-domain "office365.com")
  325. (smtpmail-default-smtp-server "smtp.office365.com")
  326. (smtpmail-stream-type starttls)
  327. (smtpmail-smtp-server "smtp.office365.com")
  328. (smtpmail-smtp-service 25)
  329. )
  330. ))
  331. ;; ---
  332. (defun my-mu4e-set-account ()
  333. "Set the account for composing a message.
  334. This function is taken from:
  335. https://www.djcbsoftware.nl/code/mu/mu4e/Multiple-accounts.html"
  336. (let* ((account
  337. (if mu4e-compose-parent-message
  338. (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir)))
  339. (string-match "/\\(.*?\\)/" maildir)
  340. (match-string 1 maildir))
  341. (completing-read (format "Compose with account: (%s) "
  342. (mapconcat #'(lambda (var) (car var))
  343. my-mu4e-account-alist "/"))
  344. (mapcar #'(lambda (var) (car var)) my-mu4e-account-alist)
  345. nil t nil nil (caar my-mu4e-account-alist))))
  346. (account-vars (cdr (assoc account my-mu4e-account-alist))))
  347. (if account-vars
  348. (mapc #'(lambda (var)
  349. (set (car var) (cadr var)))
  350. account-vars)
  351. (error "No email account found"))))
  352. (add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account)
  353. ;;-+-+-+-+-+-+-+-+-+-+-+-+
  354. ;;---------
  355. ;; mu4e-maildirs-extension
  356. (use-package mu4e-maildirs-extension
  357. :ensure t
  358. :init
  359. (mu4e-maildirs-extension)
  360. :custom
  361. (mu4e-maildirs-extension-custom-list '("/Gmail/INBOX" "/Exchange/INBOX" "/Hotmail/INBOX"))
  362. )
  363. ;; mu4e-alert
  364. (use-package mu4e-alert
  365. :ensure t
  366. :after mu4e
  367. :init
  368. (setq mu4e-alert-interesting-mail-query
  369. (concat
  370. "flag:unread maildir:/Exchange/INBOX "
  371. "OR "
  372. "flag:unread maildir:/Gmail/INBOX"
  373. ))
  374. (mu4e-alert-enable-mode-line-display)
  375. (defun gjstein-refresh-mu4e-alert-mode-line ()
  376. (interactive)
  377. (mu4e~proc-kill)
  378. (mu4e-alert-enable-mode-line-display)
  379. )
  380. (run-with-timer 0 60 'gjstein-refresh-mu4e-alert-mode-line))
  381. ;; helm
  382. (use-package helm-mu
  383. :ensure t
  384. :config
  385. ;;(define-key mu4e-main-mode-map "s" 'helm-mu)
  386. ;;(define-key mu4e-headers-mode-map "s" 'helm-mu)
  387. ;;(define-key mu4e-view-mode-map "s" 'helm-mu)
  388. )
  389. (custom-set-variables
  390. ;; custom-set-variables was added by Custom.
  391. ;; If you edit it by hand, you could mess it up, so be careful.
  392. ;; Your init file should contain only one such instance.
  393. ;; If there is more than one, they won't work right.
  394. '(custom-safe-themes
  395. (quote
  396. ("bf387180109d222aee6bb089db48ed38403a1e330c9ec69fe1f52460a8936b66" default)))
  397. '(pdf-tools-handle-upgrades nil)
  398. '(safe-local-variable-values
  399. (quote
  400. ((set-fill-column . 5000)
  401. (set-fill-column . 2000)
  402. (TeX-auto-save . t)
  403. (TeX-parse-self . t)
  404. (org-attach-directory . "students/")
  405. (org-attach-use-inheritance . t)
  406. (org-attach-preferred-new-method . ask))))
  407. '(send-mail-function (quote smtpmail-send-it)))
  408. (custom-set-faces
  409. ;; custom-set-faces was added by Custom.
  410. ;; If you edit it by hand, you could mess it up, so be careful.
  411. ;; Your init file should contain only one such instance.
  412. ;; If there is more than one, they won't work right.
  413. '(org-document-title ((t (\,@headline (\,@ variable-tuple) :height 1.5 :underline nil))))
  414. '(org-level-1 ((t (\,@headline (\,@ variable-tuple) :height 1.25))))
  415. '(org-level-2 ((t (\,@headline (\,@ variable-tuple) :height 1.15))))
  416. '(org-level-3 ((t (\,@headline (\,@ variable-tuple) :height 1.12))))
  417. '(org-level-4 ((t (\,@headline (\,@ variable-tuple) :height 1.1))))
  418. '(org-level-5 ((t (\,@headline (\,@ variable-tuple)))))
  419. '(org-level-6 ((t (\,@headline (\,@ variable-tuple)))))
  420. '(org-level-7 ((t (\,@headline (\,@ variable-tuple)))))
  421. '(org-level-8 ((t (\,@headline (\,@ variable-tuple))))))