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.

438 lines
14 KiB

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