This commit is contained in:
Madeleine Sydney
2025-03-23 23:16:03 -06:00
parent c3c1359b4f
commit ef9943b707
22 changed files with 300 additions and 106 deletions

View File

@@ -0,0 +1,27 @@
;;; .yas-setup.el -*- lexical-binding: t; -*-
(require 'dash)
(require 's)
(defun snippet-bibtex--make-id ()
(let ((surname (--> (or (yas-field-value 2)
"surname")
(s-downcase it)
(string-to-list it)
(-take-while (lambda (x) (/= x ?,)) it)
(-filter (lambda (x) (not (memq x '(?- ?\s)))) it)
(apply #'string it)))
(year (--> (or (yas-field-value 3)
"1234")
(string-to-list it)
(-take-while (lambda (x) (<= ?0 x ?9)) it)
(apply #'string it)))
(keyword (or (-some--> (or (yas-field-value 1)
"keyword")
(s-downcase it)
(s-split-words it)
(-find (lambda (x)
(not (member x '("the" "on" "of" "a" "when"))))
it))
"keyword")))
(concat surname year keyword)))

View File

@@ -0,0 +1,13 @@
# -*- mode: snippet -*-
# name: Article
# uuid:
# key: @art
# condition: t
# --
@article{${1:$(snippet-bibtex--make-id)}
, title = {${1:Principia Mathematica}}
, author = {${2:of Sinope, Diogenes}}
, year = {${3:1992}}
, url = {${4:https://example.com/}}
, urldate = {${5:`(format-time-string "%Y-%m-%d")`}}
}