From 190627d982ee3acf2808751910c1f75e245365d9 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 20 Dec 2024 16:11:38 -0800 Subject: [PATCH] Better bibtex URL highlighting and matching --- init.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init.el b/init.el index 3e647b1..541d13d 100644 --- a/init.el +++ b/init.el @@ -1379,6 +1379,17 @@ COMMAND and COMINT are like `compile'." ;; Bibtex (built in) (require 'bibtex) +;; Better URL highlighting and matching +(dolist (field '("howpublished" "url")) + (add-to-list 'bibtex-generate-url-list + `((,field . ,(rx "http" (? "s") "://" (+ (not "}")))) + "%s" + (,field + ,(rx (? (or "\\url{" "{")) (group "http" (? "s") "://" + (+ (not "}"))) + (? "}")) + ,(lambda (field) + (match-string 1 field)))))) (defun my/bibtex-in-entry-p (&optional exclude-braces) "Return t is point is inside a BibTeX entry. When EXCLUDE-BRACES is non-nil, don't count the first and last brace of the