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.

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