Skip to content

Instantly share code, notes, and snippets.

@karthink
karthink / reftex-in-org.el
Last active February 16, 2024 08:37
Configuration for an improved reftex experience in Emacs' Org mode
(use-package org-mode
:hook (org-mode . eldoc-mode)
:config
(font-lock-add-keywords
'org-mode
'(("\\(\\(?:\\\\\\(?:label\\|ref\\|eqref\\)\\)\\){\\(.+?\\)}"
(1 font-lock-keyword-face)
(2 font-lock-constant-face)))))
(use-package reftex
(require 'org-pcomplete)
(require 'org-compat)
(eval-when-compile (require 'cl-lib))
(defun pcomplete/org-mode/file-option/bibliography ()
"Complete arguments for the #+BIBLIOGRAPHY file option."
(require 'oc)
(pcomplete-here (append
(mapcar (lambda (bibfile)
(propertize bibfile
@karthink
karthink / org-latex-preview-idle-precompilation.el
Last active June 5, 2023 08:54
Precompile Org-mode's LaTeX headers in the background.
;; Precompilation freezes emacs, do it in the background when possible.
(defun my/org-latex-preview-precompile-idle ()
(when (featurep 'async)
(run-with-idle-timer
2 nil #'my/org-latex-preview-precompile-async
(current-buffer))))
(defun my/org-latex-preview-precompile-async (&optional org-buf)
(when (buffer-live-p org-buf)
(with-current-buffer org-buf
(defun org-latex-preview-check-health (&optional inter)
"Inspect the relevent system state and setup.
INTER signals whether the function has been called interactively."
(interactive (list t))
;; Collect information
(let* ((diag `(:interactive ,inter)))
(plist-put diag :org-version org-version)
;; modified variables
(plist-put diag :modified
(let ((list))
@karthink
karthink / repeat-mode-config.el
Created July 3, 2022 10:59
repeat-mode configuration with which-key for Emacs 28
(use-package repeat
:if (version< "28.0" emacs-version)
:bind ("H-z" . repeat)
:hook (after-init . my/repeat-mode)
:config
(defun my/repeat-mode ()
(let ((inhibit-message t)
(message-log-max nil))
(repeat-mode)))
@karthink
karthink / fast-latex-input.el
Last active April 11, 2024 08:26
Configuration for super-fast Latex input using AucTeX, CDLatex and a bit of YaSnippet. See https://karthinks.com/software/latex-input-for-impatient-scholars
;; This elisp code uses use-package, a macro to simplify configuration. It will
;; install it if it's not available, so please edit the following code as
;; appropriate before running it.
;; Note that this file does not define any auto-expanding YaSnippets.
;; Install use-package
(package-install 'use-package)
;; AucTeX settings - almost no changes
@karthink
karthink / avy-actions.el
Last active January 21, 2024 00:32
Supplementary code for Avy actions for Emacs
;; Code used in the demos at https://karthinks.com/software/avy-can-do-anything
;; Tweak as desired.
(package-install 'avy)
(setq avy-keys '(?q ?e ?r ?y ?u ?o ?p
?a ?s ?d ?f ?g ?h ?j
?k ?l ?' ?x ?c ?v ?b
?n ?, ?/))