init.el 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. ;; init.el -*- lexical-binding: t; -*-
  2. ;;-----------------------------------------------------------------------;;
  3. ;; TERROR EMACS ;;
  4. ;; A simple Emacs setup for the terror of academic life ;;
  5. ;; ;;
  6. ;; This program is free software: you can redistribute it and/or modify ;;
  7. ;; it under the terms of the GNU General Public License as published by ;;
  8. ;; the Free Software Foundation, either version 3 of the License, or ;;
  9. ;; any later version. ;;
  10. ;; ;;
  11. ;; This program is distributed in the hope that it will be useful, ;;
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;
  14. ;; GNU General Public License for more details. ;;
  15. ;; ;;
  16. ;; You should have received a copy of the GNU General Public License ;;
  17. ;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;
  18. ;;-----------------------------------------------------------------------;;
  19. (setq gc-cons-threshold (* 50 1000 1000))
  20. (setq user-full-name "DELM"
  21. user-mail-address "dlmayhem@riseup.net")
  22. (menu-bar-mode -1)
  23. (scroll-bar-mode -1)
  24. (tool-bar-mode -1)
  25. (tooltip-mode -1)
  26. (set-fringe-mode 4)
  27. (global-visual-line-mode 1)
  28. (global-auto-revert-mode 1)
  29. (if (window-system)
  30. (global-hl-line-mode 1))
  31. (set-face-font 'default "JetBrainsMono 12")
  32. (set-face-font 'variable-pitch "JetBrainsMono 12")
  33. (set-fontset-font "fontset-default" 'greek
  34. (font-spec :family "Gentium" :size 22))
  35. (fset 'yes-or-no-p 'y-or-n-p)
  36. (delete-selection-mode 1)
  37. (column-number-mode)
  38. (put 'downcase-region 'disabled nil)
  39. (set-frame-parameter (selected-frame) 'internal-border-width 20)
  40. (dolist (mode '(c-mode-hook
  41. emacs-lisp-mode-hook
  42. sh-mode-hook
  43. python-mode-hook
  44. LaTeX-mode-hook))
  45. (add-hook mode (lambda () (display-line-numbers-mode t))))
  46. (setq-default cursor-in-non-selected-windows nil
  47. frame-title-format '("%f [%m]"))
  48. (setq default-fill-column 100
  49. make-backup-files nil
  50. inhibit-startup-message t
  51. use-dialog-box nil
  52. vc-follow-symlinks t
  53. tramp-default-method "ssh"
  54. custom-file "~/.emacs.d/custom.el"
  55. global-auto-revert-non-file-buffers t
  56. message-kill-buffer-on-exit t
  57. large-file-warning-threshold nil)
  58. (load custom-file)
  59. (require 'package)
  60. (setq package-archives '(("melpa" . "https://melpa.org/packages/")
  61. ("nongnu" . "https://elpa.nongnu.org/nongnu/")
  62. ("elpa" . "https://elpa.gnu.org/packages/")))
  63. (package-initialize)
  64. (unless package-archive-contents
  65. (package-refresh-contents))
  66. (unless (package-installed-p 'use-package)
  67. (package-install 'use-package))
  68. (require 'use-package)
  69. (setq use-package-always-ensure t)
  70. (use-package vertico
  71. :ensure t
  72. :init
  73. (vertico-mode))
  74. (use-package vertico-directory
  75. :after vertico
  76. :ensure nil
  77. :bind (:map vertico-map
  78. ("RET" . vertico-directory-enter)
  79. ("DEL" . vertico-directory-delete-char)
  80. ("M-DEL" . vertico-directory-delete-word))
  81. :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
  82. (use-package savehist
  83. :init
  84. (savehist-mode))
  85. (use-package marginalia
  86. :after vertico
  87. :ensure t
  88. :init
  89. (marginalia-mode)
  90. :custom
  91. (marginalia-align 'right))
  92. (use-package embark
  93. :ensure t
  94. :bind (("C-." . embark-act)
  95. ("C-;" . embark-dwim)
  96. ("C-h B" . embark-bindings))
  97. :init
  98. (setq prefix-help-command #'embark-prefix-help-command)
  99. :config
  100. (add-to-list 'display-buffer-alist
  101. '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
  102. nil
  103. (window-parameters (mode-line-format . none)))))
  104. (use-package orderless
  105. :ensure t
  106. :after vertico
  107. :custom
  108. (completion-styles '(orderless basic)))
  109. (use-package corfu
  110. :custom
  111. (corfu-auto t)
  112. (corfu-quit-no-match t)
  113. (corfu-separator ?\s)
  114. :init
  115. (global-corfu-mode))
  116. (use-package corfu-terminal
  117. :config
  118. (unless (display-graphic-p)
  119. (corfu-terminal-mode +1)))
  120. (use-package doom-themes
  121. :if window-system
  122. :init
  123. (load-theme 'doom-wilmersdorf t))
  124. (use-package solaire-mode
  125. :config
  126. (add-to-list 'solaire-mode-themes-to-face-swap 'doom-wilmersdorf)
  127. (setq solaire-mode-auto-swap-bg t)
  128. (solaire-global-mode +1))
  129. (use-package doom-modeline
  130. :init
  131. (doom-modeline-mode 1)
  132. :custom
  133. (doom-modeline-height 15))
  134. (use-package nerd-icons
  135. :custom
  136. (nerd-icons-font-family "Symbols Nerd Font Mono"))
  137. (use-package which-key
  138. :defer 0
  139. :config
  140. (which-key-mode)
  141. (setq which-key-idle-delay 0.3))
  142. (use-package gnus
  143. :bind
  144. ("C-c g" . gnus))
  145. (use-package magit
  146. :bind ("C-x g" . magit-status))
  147. (use-package smartparens
  148. :hook (prog-mode . smartparens-mode))
  149. (use-package rainbow-delimiters
  150. :hook (prog-mode . rainbow-delimiters-mode))
  151. (use-package paren
  152. :config
  153. (show-paren-mode 1))
  154. (use-package rainbow-mode
  155. :defer t
  156. :hook (org-mode
  157. emacs-lisp-mode
  158. web-mode
  159. c-mode))
  160. (use-package simple-httpd
  161. :ensure t)
  162. (use-package htmlize
  163. :ensure t)
  164. (use-package writeroom-mode
  165. :bind ("C-c d" . writeroom-mode)
  166. :config
  167. (advice-add 'text-scale-adjust :after
  168. #'visual-fill-column-adjust))
  169. (use-package yasnippet
  170. :defer t
  171. :config
  172. (setq yas-snippet-dirs '("~/.emacs.d/templates/yasnippet"))
  173. (yas-global-mode 1))
  174. (use-package lorem-ipsum
  175. :bind (("C-c M-p" . lorem-ipsum-insert-paragraphs)
  176. ("C-c M-s" . lorem-ipsum-insert-sentences)))
  177. (use-package pdf-tools
  178. :defer t
  179. :custom
  180. (pdf-view-midnight-colors '("#c6c6c6" . "#1f2024")))
  181. (pdf-loader-install)
  182. (use-package pdf-view-restore
  183. :after pdf-tools
  184. :config
  185. (add-hook 'pdf-view-mode-hook 'pdf-view-restore-mode))
  186. (use-package nov
  187. :defer t
  188. :mode ("\\.epub\\'" . nov-mode))
  189. (use-package citar
  190. :defer t
  191. :bind (("C-c b" . citar-insert-citation)
  192. ("M-p" . citar-org-update-prefix-suffix)
  193. :map minibuffer-local-map
  194. ("M-b" . citar-insert-preset))
  195. :custom
  196. (citar-bibliography '("~/Documentos/refs.bib"))
  197. :hook
  198. (LaTeX-mode . citar-capf-setup)
  199. (org-mode . citar-capf-setup))
  200. (use-package citar-embark
  201. :after citar embark
  202. :no-require
  203. ;; :init
  204. ;; (setq citar-at-point-function 'embark-act)
  205. :config (citar-embark-mode))
  206. (use-package ebib
  207. :defer t
  208. :config
  209. (require 'ebib-biblio)
  210. (define-key ebib-index-mode-map (kbd "B") #'ebib-biblio-import-doi)
  211. (define-key biblio-selection-mode-map (kbd "e") #'ebib-biblio-selection-import))
  212. (use-package elfeed
  213. :no-require t
  214. :bind ("C-x w" . elfeed))
  215. (use-package elfeed-org
  216. :ensure t
  217. :after elfeed
  218. :config
  219. (elfeed-org)
  220. (setq rmh-elfeed-org-files (list "~/.emacs.d/elfeed.org")))
  221. (use-package arxiv-mode
  222. :ensure t
  223. :bind ("C-x x" . arxiv-search)
  224. :config
  225. (setq arxiv-default-download-folder "~/Documentos/"))
  226. (use-package org
  227. :commands (org-capture org-agenda)
  228. :bind (("C-c l" . org-store-link)
  229. ("C-c a" . org-agenda)
  230. ("C-c c" . org-capture))
  231. :hook (org-mode . smartparens-mode)
  232. :custom
  233. (org-export-backends
  234. '(beamer html icalendar latex md odt))
  235. (org-capture-templates
  236. '(("b" "Birthday" entry
  237. (file+headline "~/Proyectos/org/agenda.org" "Birthdays")
  238. "** BIRTHDAY %^{Name}\n%<<%Y-%^{Month number}-%^{Day number} ++1y>>%?"
  239. :empty-lines-before 1 :empty-lines-after 1
  240. :immediate-finish t)
  241. ("d" "Deadline" entry
  242. (file+headline "~/Proyectos/org/agenda.org" "Deadlines")
  243. "** TODO %^{Task}\nDEADLINE %^T%?"
  244. :empty-lines-before 1 )
  245. ("e" "Event")
  246. ("ea" "Academic event" entry
  247. (file+headline "~/Proyectos/org/agenda.org" "Events")
  248. "** %^{|CONGRESS|SEMINAR|SYMPOSIUM} %^{Name}\n- SCHEDULED %^t--%^t\n- Location :: %^{Place/link}%?"
  249. :empty-lines-before 1 :empty-lines-after 1)
  250. ("ec" "Craic" entry
  251. (file+headline "~/Proyectos/org/agenda.org" "Events")
  252. "** PARTY %^{Name}\n- SCHEDULED %^T\n- Location :: %^{Place/link}%?"
  253. :empty-lines-before 1 :empty-lines-after 1)
  254. ("ef" "Festival" entry
  255. (file+headline "~/Proyectos/org/agenda.org" "Events")
  256. "** FEST %^{Name}\n- SCHEDULED %^t--%^t\n- Location :: %^{Place/link}%?"
  257. :empty-lines-before 1 :empty-lines-after 1)
  258. ("eg" "Gig" entry
  259. (file+headline "~/Proyectos/org/agenda.org" "Events")
  260. "** CONCERT %^{Band}\n- SCHEDULED %^T\n- Location :: %^{Place/link}%?"
  261. :empty-lines-before 1 :empty-lines-after 1)
  262. ("em" "Meeting" entry
  263. (file+headline "~/Proyectos/org/agenda.org" "Events")
  264. "** MEETING %^{Meeting}\n- SCHEDULED %^T--%^T\n- Location :: %^{Place/link}%?"
  265. :empty-lines-before 1 :empty-lines-after 1)
  266. ("ep" "Practice" entry
  267. (file+headline "~/Proyectos/org/agenda.org" "Events")
  268. "** PRACTICE %^{What?}\n- SCHEDULED %^T\n- Location :: %^{Place/link}%?"
  269. :empty-lines-before 1 :empty-lines-after 1)
  270. ("et" "Talk" entry
  271. (file+headline "~/Proyectos/org/agenda.org" "Events")
  272. "** TALK %^{Talk's name}\n- Author :: %^{Name}\n- SCHEDULED %^T\n- Location :: %^{Place/link}%?"
  273. :empty-lines-before 1 :empty-lines-after 1)
  274. ("j" "Task" entry
  275. (file+headline "~/Proyectos/org/agenda.org" "Frequent Tasks")
  276. "** %^{Task}\n %^T%?"
  277. :empty-lines-before 1 :empty-lines-after 1)
  278. ("l" "Loaned object" entry
  279. (file+headline "~/.agenda.org" "On loan")
  280. "** ON LOAN %^{|BOOK|MUSIC|OTHER}\n- Title :: %^{Title}\n- To whom :: %^{Name}\n- Date :: %t%?"
  281. :empty-lines-before 1 :empty-lines-after 1
  282. :immediate-finish t)
  283. ("t" "To-Do" entry
  284. (file+headline "~/Proyectos/org/agenda.org" "To-Do")
  285. "** TODO %^{To do}\n%?"
  286. :empty-lines-before 1 :empty-lines-after 1)))
  287. (org-todo-keywords
  288. '((sequence "TODO(t)" "DONE(d)" "ON LOAN(l)")))
  289. :config
  290. (setq org-agenda-files '("~/Proyectos/org/agenda.org")
  291. org-ellipsis " ▾"
  292. org-footnote-auto-adjust t
  293. org-fontify-quote-and-verse-blocks t
  294. org-log-done 'time
  295. org-capture-bookmark nil
  296. org-html-validation-link nil
  297. org-startup-indented t
  298. org-startup-folded nil
  299. org-confirm-babel-evaluate nil
  300. org-image-actual-width 550
  301. org-format-latex-options (plist-put org-format-latex-options :scale 3.0)))
  302. ;; (use-package oc
  303. ;; :defer t
  304. ;; :init
  305. ;; (require 'oc-csl)
  306. ;; (require 'oc-biblatex)
  307. ;; (require 'oc-natbib)
  308. ;; (setq org-cite-global-bibliography '("~/Documentos/refs.bib")))
  309. (with-eval-after-load 'org
  310. (org-babel-do-load-languages
  311. 'org-babel-load-languages
  312. '((C . t)
  313. (scheme . t)
  314. (python . t)
  315. (shell . t)
  316. (dot . t)
  317. (latex . t)
  318. (latex-as-png . t)))
  319. (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images))
  320. (use-package org-roam
  321. :ensure t
  322. :init
  323. (setq org-roam-v2-ack t)
  324. :custom
  325. (org-roam-directory (file-truename "~/Proyectos/org/roam"))
  326. (org-roam-capture-templates
  327. '(("a" "Author" plain
  328. (file "~/.emacs.d/templates/roam/author.org")
  329. :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
  330. "#+title: ${title}\n")
  331. :unnarrowed t)
  332. ("b" "Bibliography" plain
  333. (file "~/.emacs.d/templates/roam/biblio.org")
  334. :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
  335. "#+title: ${title}\n")
  336. :unnarrowed t)
  337. ("c" "Concept" plain
  338. (file "~/.emacs.d/templates/roam/concept.org")
  339. :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
  340. "#+title: ${title}\n")
  341. :unnarrowed t)
  342. ("d" "Default" plain
  343. "%?"
  344. :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  345. :unnarrowed t)
  346. ("f" "Field" plain
  347. (file "~/.emacs.d/templates/roam/field.org")
  348. :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
  349. "#+title: ${title}\n")
  350. :unnarrowed t)
  351. ("q" "Quote" plain
  352. (file "~/.emacs.d/templates/roam/quote.org")
  353. :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
  354. "#+title: ${title}\n")
  355. :unnarrowed t)))
  356. :bind (("C-c n l" . org-roam-buffer-toggle)
  357. ("C-c n f" . org-roam-node-find)
  358. ("C-c n i" . org-roam-node-insert)
  359. ("C-c n g" . org-roam-ui-mode)
  360. ("C-c n c" . org-roam-capture)
  361. ("C-c n j" . org-roam-dailies-capture-today))
  362. :config
  363. (setq org-roam-node-display-template
  364. (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
  365. (org-roam-setup)
  366. (require 'org-roam-protocol))
  367. (use-package org-roam-ui
  368. :after org-roam
  369. :config
  370. (setq org-roam-ui-sync-theme t
  371. org-roam-ui-follow t
  372. org-roam-ui-update-on-save t
  373. org-roam-ui-open-on-start t))
  374. (use-package org-contrib
  375. :after org
  376. :config
  377. (require 'ox-extra)
  378. (ox-extras-activate '(latex-header-blocks ignore-headlines)))
  379. (use-package ox-twbs
  380. :after org)
  381. (use-package ob-latex-as-png
  382. :after org)
  383. (use-package org-bullets
  384. :no-require t
  385. :custom
  386. (org-bullets-bullet-list '("◉" "●" "○" "●" "○" "●")))
  387. (use-package hide-lines)
  388. (use-package hide-mode-line
  389. :defer t)
  390. (defun terror/slide-setup ()
  391. (global-hl-line-mode -1)
  392. (setq org-hide-emphasis-markers t)
  393. (org-bullets-mode 1)
  394. (setq text-scale-mode-amount 3)
  395. (text-scale-mode 1)
  396. (set-frame-parameter (selected-frame)
  397. 'internal-border-width 75)
  398. (org-display-inline-images)
  399. (toggle-frame-fullscreen)
  400. (hide-mode-line-mode 1)
  401. (hide-lines-matching "#\\+begin")
  402. (hide-lines-matching "#\\+end"))
  403. (defun terror/slide-end ()
  404. (global-hl-line-mode 1)
  405. (setq org-hide-emphasis-markers nil)
  406. (org-bullets-mode -1)
  407. (setq text-scale-mode-amount 0)
  408. (text-scale-mode -1)
  409. (set-frame-parameter (selected-frame)
  410. 'internal-border-width 20)
  411. (toggle-frame-fullscreen)
  412. (hide-mode-line-mode -1)
  413. (hide-lines-show-all)
  414. (org-fold-show-all))
  415. (use-package org-tree-slide
  416. :after org
  417. :bind ("C-c p" . org-tree-slide-mode)
  418. :hook ((org-tree-slide-play . terror/slide-setup)
  419. (org-tree-slide-stop . terror/slide-end))
  420. :config
  421. (setq org-tree-slide-slide-in-effect nil
  422. org-image-actual-width nil
  423. org-tree-slide-header t
  424. org-tree-slide-breadcrumbs " > "
  425. org-tree-slide-activate-message "Let's begin..."
  426. org-tree-slide-deactivate-message "The end :)"))
  427. (use-package latex
  428. :ensure auctex
  429. :defer t
  430. :init
  431. (server-force-delete)
  432. :custom
  433. (TeX-source-correlate-mode t)
  434. (TeX-source-correlate-start-server t)
  435. :config
  436. (setq TeX-view-program-selection '((output-pdf "PDF Tools")))
  437. (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))
  438. (use-package markdown-mode
  439. :ensure t
  440. :commands (markdown-mode gfm-mode)
  441. :mode (("README\\.md\\'" . gfm-mode)
  442. ("\\.md\\'" . markdown-mode)
  443. ("\\.markdown\\'" . markdown-mode)))
  444. (use-package lilypond-mode
  445. :defer t
  446. :load-path "var/lisp/lilypond-mode"
  447. :config
  448. (setq auto-mode-alist
  449. (cons '("\\.ly$" . LilyPond-mode) auto-mode-alist))
  450. (add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock)))
  451. (setq LilyPond-command-alist '(("LilyPond" "lilypond %s" "%s" "%l" "View")
  452. ("2PS" "lilypond -f ps %s" "%s" "%p" "ViewPS")
  453. ("Book" "lilypond-book %x" "%x" "%l" "LaTeX")
  454. ("LaTeX" "latex '\\nonstopmode\\input %l'" "%l" "%d" "ViewDVI")
  455. ("View" "open %f")
  456. ("ViewPDF" "open %f")
  457. ("ViewPS" "gv --watch %p")
  458. ("Midi" "")
  459. ("MidiAll" ""))))
  460. (use-package dired
  461. :ensure nil
  462. :defer 1
  463. :config
  464. (setq dired-recursive-copies 'always
  465. dired-listing-switches "--group-directories-first -alh"))
  466. (use-package dired-hide-dotfiles
  467. :after dired
  468. :hook (dired-mode . dired-hide-dotfiles-mode)
  469. :config
  470. (define-key dired-mode-map "." #'dired-hide-dotfiles-mode))
  471. (use-package dired-open
  472. :after dired
  473. :config
  474. (setq dired-open-extensions '(("mp3" . "mpv")
  475. ("mp4" . "mpv")
  476. ("mkv" . "mpv")
  477. ("png" . "nsxiv")
  478. ("gif" . "nsxiv")
  479. ("jpg" . "nsxiv")
  480. ("jpeg" . "nsxiv"))))
  481. (add-hook 'emacs-startup-hook
  482. (lambda ()
  483. (message "Emacs ready in %s with %d garbage collections."
  484. (format "%.2f seconds"
  485. (float-time
  486. (time-subtract after-init-time before-init-time)))
  487. gcs-done)))
  488. (setq gc-cons-threshold (* 2 1000 1000))
  489. ;;; Happy hacking! ;;;