;; -*- lexical-binding: t; -*-
(setq termux-p (string-suffix-p "android" system-configuration))
(if termux-p
(setq my-notes-directory "~/documents/org/reading-notes")
(setq my-notes-directory "~/Dropbox/org/reading-notes"
my-bibliography "~/Dropbox/texmf/bibtex/bib/misc/rvf.bib"
my-library-path "~/Documents/References/"))
(use-package emacs
:bind
([(f2) (f2)] . indent-according-to-mode)
([(f2) (r)] . recentf)
([(super down)] . duplicate-line-forward)
([(super up)] . duplicate-line-backward)
:config
(ido-mode 1)
:custom
(confirm-nonexistent-file-or-buffer nil)
(custom-file (concat user-emacs-directory "custom.el"))
(frame-title-format "%b: %+%+ %f")
(mouse-drag-copy-region t)
:init
(global-visual-line-mode)
(recentf-mode)
(load custom-file t)
;; From: [email protected] (Sandip Chitale)
;; Newsgroups: gnu.emacs.sources
;; Subject: CODE: Duplicate line or region backward or forward
;; Date: 7 Feb 2004 12:15:35 -0800
(defun duplicate-line-backward ()
"Duplicate the current line backward."
(interactive "*")
(save-excursion
(let ((contents (buffer-substring
(line-beginning-position)
(line-end-position))))
(beginning-of-line)
(insert contents ?\n)))
(previous-line 1))
(defun duplicate-line-forward ()
"Duplicate the current line forward."
(interactive "*")
(save-excursion
(let ((contents (buffer-substring
(line-beginning-position)
(line-end-position))))
(end-of-line)
(insert ?\n contents)))
(next-line 1)))
(straight-use-package 'use-package)
https://www.gnu.org/software/auctex/
AUCTeX is an extensible package for writing and formatting TeX files in GNU Emacs and XEmacs. It supports many different TeX macro packages, including AMS-TeX, LaTeX, Texinfo, ConTeXt, and docTeX (dtx files).
(use-package tex
:straight auctex
:mode ("\\.tikz\\'" . latex-mode)
:init
(defun my-latex-config ()
(TeX-add-symbols '("deg"))
(TeX-add-symbols '("emph" 1))
(TeX-add-symbols '("ne"))
(TeX-add-symbols '("to"))
(LaTeX-add-environments '("definition" LaTeX-env-label)
'("theorem" LaTeX-env-label)
'("lemma" LaTeX-env-label)
'("corollary" LaTeX-env-label)
'("proposition" LaTeX-env-label)
'("problem" LaTeX-env-label)
'("remark" LaTeX-env-label)
'("example" LaTeX-env-label))
(add-to-list 'LaTeX-label-alist '("definition" . "def:"))
(add-to-list 'LaTeX-label-alist '("theorem" . "thm:"))
(add-to-list 'LaTeX-label-alist '("lemma" . "lem:"))
(add-to-list 'LaTeX-label-alist '("corollary" . "cor:"))
(add-to-list 'LaTeX-label-alist '("proposition" . "prop:"))
(add-to-list 'LaTeX-label-alist '("problem" . "prob:"))
(add-to-list 'LaTeX-label-alist '("remark" . "rem:"))
(add-to-list 'LaTeX-label-alist '("example" . "exa:"))
(add-to-list 'reftex-label-alist '("definition" ?d "def:" "~\\ref{%s}" nil ("Definition" "definition")))
(add-to-list 'reftex-label-alist '("theorem" ?h "thm:" "~\\ref{%s}" nil ("Theorem" "theorem")))
(add-to-list 'reftex-label-alist '("lemma" ?l "lem:" "~\\ref{%s}" nil ("Lemma" "lemma")))
(add-to-list 'reftex-label-alist '("corollary" ?c "cor:" "~\\ref{%s}" nil ("Corollary" "corollary")))
(add-to-list 'reftex-label-alist '("proposition" ?p "prop:" "~\\ref{%s}" nil ("Proposition" "proposition")))
(add-to-list 'reftex-label-alist '("problem" ?b "prob:" "~\\ref{%s}" nil ("Problem" "problem")))
(add-to-list 'reftex-label-alist '("remark" ?r "rem:" "~\\ref{%s}" nil ("Remark" "remark")))
(add-to-list 'reftex-label-alist '("example" ?e "rem:" "~\\ref{%s}" nil ("Example" "example")))
(TeX-run-style-hooks "tikz")
(TeX-run-style-hooks "tkz-graph")
(TeX-run-style-hooks "tkz-berge"))
:custom
(TeX-auto-save t)
(TeX-electric-escape t)
(TeX-insert-braces nil)
(TeX-parse-self t)
(TeX-save-query nil)
(reftex-plug-into-AUCTeX t)
(reftex-use-external-file-finders t)
:hook
(LaTeX-mode . turn-on-cdlatex)
(LaTeX-mode . my-latex-config)
(LaTeX-mode . turn-on-reftex))
https://github.com/pzorin/bibretrieve
An Emacs library for searching and downloading BibTeX entries from the web.
(use-package bibretrieve
:straight t)
(use-package bibtex
:straight (:type built-in)
:bind (:map bibtex-mode-map
("<f5> b" . bibretrieve)
("<f5> m" . mark-sexp))
:custom
(bibtex-autokey-year-title-separator "-")
(bibtex-autokey-year-length 4)
(bibtex-autokey-names nil)
(bibtex-autokey-name-separator "-")
(bibtex-autokey-name-year-separator "-")
(bibtex-autokey-titleword-separator "-")
(bibtex-autokey-titleword-length "All")
(bibtex-autokey-titlewords "All")
(bibtex-autokey-titleword-ignore "")
:init
(defun bibtex-generate-autokey ()
(let* ((names (bibtex-autokey-get-names))
(year (bibtex-autokey-get-year))
(title (bibtex-autokey-get-title))
(autokey (concat year
(unless (or (equal names "")
(equal year ""))
bibtex-autokey-name-year-separator)
names
(unless (or (and (equal names "")
(equal year ""))
(equal title ""))
bibtex-autokey-year-title-separator)
title)))
autokey)))
https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex/
CDLaTeX is a minor mode for Emacs supporting fast insertion of environment templates and math stuff in LaTeX. Similar commands are also offered as part of the AUCTeX package, but it is not the same - CDLaTeX focuses on speediness for inserting LaTeX constructs. I myself am using CDLaTeX on top of AUCTeX.
The settings in cdlatex-math-symbol-alist
are useful also when writing math in org-mode.
It was needed to customize cdlatex-takeover-parenthesis
, see this issue.
(use-package cdlatex
:straight t
:custom
(cdlatex-math-symbol-alist
'(( ?c ("\\colon"))
( ?m ("\\mu" "\\mapsto"))
( ?p ("\\pi" "\\varpi" "\\perp"))
( ?o ("\\omega" "\\oplus"))
( ?O ("\\Omega" "\\mathrm{Orb}"))
( ?S ("\\Sigma" "\\mathrm{Stab}"))
( ?T ("\\bigtriangleup"))
( ?- ("\\cap" "\\leftrightarrow" "\\longleftrightarrow"))
( ?. ("\\ldots" "\\cdots" "\\cdot"))
( ?* ("\\times" "\\otimes"))
( ?< ("\\leq" "\\langle" "\\trianglelefteq"))
( ?> ("\\geq" "\\rangle" "\\trianglerighteq"))
( ?= ("\\simeq"))
( ?\[ ("\\subseteq"))))
(cdlatex-math-modify-alist
'(( ?a "\\overrightarrow" nil t nil nil)
( ?k "\\mathfrak" nil t nil nil)
( ?B "\\mathbb" nil t nil nil)))
(cdlatex-command-alist
'(("bin" "Insert \\binom{}{}"
"\\binom{?}{}" cdlatex-position-cursor nil nil t)
("norm" "Insert \\Vert \\Vert"
"\\Vert ?\\Vert" cdlatex-position-cursor nil nil t)
("gen" "Insert \\langle \\rangle"
"\\langle ?\\rangle" cdlatex-position-cursor nil nil t)
("set" "Insert a set"
"\\{?\\mid \\}" cdlatex-position-cursor nil nil t)))
(cdlatex-simplify-sub-super-scripts nil)
(cdlatex-takeover-parenthesis nil))
https://github.com/emacs-citar/citar
Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
- Inserting a bibtex entry to a bibtex file: run
M-x citar-open
, then select the entry, then runC-=
, (embark-act) and choose.
(use-package citar
:straight t
:bind
([(f7)] . citar-open)
("<f5> b" . citar-insert-bibtex)
:custom
(citar-bibliography my-bibliography)
(citar-library-paths `(,my-library-path))
(citar-notes-paths `(,my-notes-directory))
:hook
(LaTeX-mode . citar-capf-setup)
(org-mode . citar-capf-setup))
(use-package citar-embark
:straight t
:after (citar embark)
:custom
(citar-at-point-function 'embark-act)
:config (citar-embark-mode))
https://github.com/minad/consult
consult.el - Consulting completing-read
consult-imenu
and consult-line
are interesting to navigate files, especially org-mode files.
I am using bms/org-roam-rg-search
is a substitute of the package deft.
(use-package consult
:straight t
:bind
("<f5> d" . bms/org-roam-rg-search)
("<f5> l" . consult-line)
("<f5> r" . consult-ripgrep)
:init
;;; https://org-roam.discourse.group/t/using-consult-ripgrep-with-org-roam-for-searching-notes/1226
(defun bms/org-roam-rg-search ()
"Search org-roam directory using consult-ripgrep. With live-preview."
(interactive)
(let ((consult-ripgrep-command
"rg --null --ignore-case --type org --line-buffered --color=always --max-columns=500 --no-heading --line-number . -e ARG OPTS"))
(consult-ripgrep org-roam-directory))))
https://github.com/minad/corfu
corfu.el - COmpletion in Region FUnction
(use-package corfu
:straight t
:custom
(corfu-auto t)
(corfu-auto-prefix 4)
:init
(global-corfu-mode))
By default, corfu
works only on .el
files. For it to be able to complete, say, by the words in a dictionary or words in the buffer, it needs extensions given by cape
.
cape.el - Completion At Point Extensions
(use-package cape
:straight t
:init
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-dict))
Note that in order to use a non-English dictionary, it is useful a local variable like cape-dict-file: "/usr/share/dict/spanish"
.
https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired.html
Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the listed files.
(use-package dired
:straight (:type built-in)
:custom
(dired-dwim-target t)
(use-package dired-x))
https://github.com/oantolin/embark
Emacs Mini-Buffer Actions Rooted in Keymaps
(use-package embark
:straight t
:bind
(("C-=" . embark-act))
:custom
(use-package embark-consult))
An interface to communicate with Jupyter kernels.
https://github.com/nnicandro/emacs-jupyter
The recent versions do not work with my ubuntu. The issue is described here. So far the workaround is to manually compile emacs-zmq.so
in straight/build
and copy it to the other folder there. Also, manually return jupyter
repo to commit 487a755
in the corresponding folder. This gives some warnings Unknown type: json-plist
, but otherwise seems to work. With these libraries it seems to work (it seems that the most important version not to upgrade is jupyter_core
).
(pycliques-dev) rafael@dell2:~$ jupyter --version
Selected Jupyter core packages...
IPython : 8.17.2
ipykernel : 6.26.0
ipywidgets : 8.1.1
jupyter_client : 8.6.1
jupyter_core : 5.7.2
jupyter_server : 1.23.4
jupyterlab : 4.0.8
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : 7.0.6
qtconsole : 5.5.1
traitlets : 5.14.3
(use-package jupyter
:if (executable-find "jupyter")
:straight t
:config
(org-babel-do-load-languages
'org-babel-load-languages
'((latex . t)
(python . t)
(jupyter . t))))
Magit is a complete text-based user interface to Git.
(use-package magit
:straight t
:bind ("C-c m" . magit-status))
https://github.com/minad/marginalia
marginalia.el - Marginalia in the minibuffer
(use-package marginalia
:straight t
:init
(marginalia-mode))
https://github.com/oantolin/math-delimiters
This package provides the command math-delimiters-insert to insert TeX/LaTeX math delimiters.
(use-package math-delimiters
:straight (:host github :repo "oantolin/math-delimiters")
:after (org cdlatex)
:bind (:map org-mode-map
("$" . math-delimiters-insert)
:map cdlatex-mode-map
("$" . nil)))
https://gitlab.com/jabranham/mixed-pitch
Mix fixed-pitch and variable-pitch fonts in Emacs
(use-package mixed-pitch
:straight t
:hook
(text-mode . mixed-pitch-mode))
https://gitlab.com/protesilaos/modus-themes
(use-package modus-themes
:straight t
:if (display-graphic-p)
:init
;; Add all your customizations prior to loading the themes
(setq modus-themes-italic-constructs t
modus-themes-bold-constructs nil
modus-themes-region '(bg-only no-extend))
(load-theme 'modus-operandi :no-confirm))
https://github.com/oantolin/orderless
Emacs completion style that matches multiple regexps in any order
(use-package orderless
:straight t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
I am setting org-src-preserve-indentation
to t
since otherwise source blocks are changed (indented) after edited.
(use-package org
:bind
("C-c a" . org-agenda)
("C-c c" . org-capture)
:init
;; see https://lists.gnu.org/archive/html/emacs-orgmode/2015-09/msg00118.html
(defmacro by-backend (&rest body)
`(cl-case org-export-current-backend ,@body))
;; Set GTD. Create Inbox.org if it does not exist
(unless (file-exists-p
(expand-file-name "Inbox.org" my-notes-directory))
(write-region "" nil (expand-file-name "inbox.org" my-notes-directory)))
(defun rvf/set-gtd ()
"Set agenda and templates for GTD"
(add-to-list 'org-agenda-files
(expand-file-name "Inbox.org" my-notes-directory))
(add-to-list 'org-capture-templates
`("@" "Inbox [mu4e]" entry
(file ,(expand-file-name "Inbox.org" my-notes-directory))
,(concat "* TODO Process \"%a\" %?\n"
"/Entered on/ %U")))
(add-to-list 'org-capture-templates
`("i" "Inbox" entry
(file ,(expand-file-name "Inbox.org" my-notes-directory))
,(concat "* TODO %?\n"
"/Entered on/ %U")))
;; http://disq.us/p/2knurta
(add-to-list 'org-capture-templates
`("w" "web" entry
(file+headline ,(expand-file-name "Inbox.org" my-notes-directory) "Web")
"* %?%i%a")))
(defun my-org-mode-hook ()
(rvf/set-gtd)
(turn-on-auto-revert-mode)
(turn-on-org-cdlatex))
:config
(require 'org-habit)
(custom-theme-set-faces
'user
`(org-level-4 ((t (:height 1.1))))
`(org-level-3 ((t (:height 1.2))))
`(org-level-2 ((t (:height 1.3))))
`(org-level-1 ((t (:height 1.5))))
`(org-document-title ((t (:height 1.75)))))
:custom
(org-file-apps
'((auto-mode . emacs)
("pdf" . "evince %s")))
(org-hide-emphasis-markers t)
(org-latex-compiler "xelatex")
(org-return-follows-link t)
(org-src-preserve-indentation t)
(org-support-shift-select t)
:hook
(org-mode . my-org-mode-hook)
(org-babel-after-execute . org-redisplay-inline-images))
https://github.com/io12/org-fragtog
Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
For some reason, by default the previews are too small, so we have to increase the scale.
(use-package org-fragtog
:straight t
:after org
:custom
(org-format-latex-header (concat org-format-latex-header "\n\\usepackage{lxfonts}"))
(org-format-latex-options (plist-put org-format-latex-options :scale 2.2))
:init
(add-hook 'org-mode-hook 'org-fragtog-mode))
By default C-M-.
is bound to org-noter-sync-current-note
.
https://github.com/org-noter/org-noter
(use-package org-noter
:straight
(:repo "org-noter/org-noter"
:host github
:type git
:files ("*.el" "modules/*.el"))
:after (org nov pdf-tools)
:bind (("<f5> n" . org-noter))
:custom
(org-noter-auto-save-last-location t)
(org-noter-notes-search-path `(,my-notes-directory)))
(use-package org-roam
:straight t
:after org
:bind
("<f8> f" . org-roam-node-find)
:custom
(org-roam-directory my-notes-directory)
:init
(org-roam-db-autosync-mode))
https://depp.brause.cc/nov.el/
Useful to open epub
files and for org-noter to annotate files in epub
format. In fact, doc-view
, which is already included, can open files in djvu
and epub
. But, it converts every page of an epub
file to an image, while nov
can be used to access the text. We have to tell Emacs to open epubs
in this mode, otherwise it will use doc-view
.
(use-package nov
:straight t
:mode ("\\.epub\\'" . nov-mode))
https://github.com/vedang/pdf-tools
PDF Tools is, among other things, a replacement of DocView for PDF files. The key difference is that pages are not pre-rendered by e.g. ghostscript and stored in the file-system, but rather created on-demand and stored in memory.
(use-package pdf-tools
:if window-system
:straight t
:config
(pdf-tools-install))
https://github.com/sagemath/sage-shell-mode
Emacs front end for SageMath
I have to use commit 80fbb4e
here, since otherwise it does not work in my system.
(use-package sage-shell-mode
:straight t)
https://github.com/sagemath/ob-sagemath
org-babel integration with SageMath
(use-package ob-sagemath
:straight t
:after sage-shell-mode)
https://github.com/Fuco1/smartparens
Smartparens is a minor mode for dealing with pairs in Emacs.
(use-package smartparens
:straight t
:config
(require 'smartparens-config)
(smartparens-global-mode 1)
(show-smartparens-global-mode 1)
(sp-local-pair 'org-mode "=" "="
:unless '(sp-point-after-word-p sp-in-math-p)
:post-handlers '(("[d1]" "SPC"))))
https://github.com/joaotavora/yasnippet
YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates include: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from TextMate’s syntax, you can even import most TextMate templates to YASnippet.
Setting yas-indent-line
to fixed has the effect that the text expanded by a snipped is indented as much as where the snipped is invoked.
(use-package yasnippet
:straight t
:config
(yas-global-mode)
:custom
(yas-indent-line 'fixed))
Snippets defined here:
key | binding | Meaning |
---|---|---|
coro | F6 c | Corollary |
defi | F6 d | Definition |
lemm | F6 l | Lemma |
proo | F6 p | Proof |
theo | F6 t | Theorem |
https://github.com/minad/vertico
vertico.el - VERTical Interactive COmpletion
(use-package vertico
:straight t
:init
(vertico-mode))