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.

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