Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(capture)!: add filter function opt for fields #44

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions citar-org-roam.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ database, and displayed in the completion interface."
:type 'string)

(defcustom citar-org-roam-template-fields
'((:citar-title . ("title"))
(:citar-author . ("author" "editor"))
(:citar-date . ("date" "year" "issued"))
(:citar-pages . ("pages"))
(:citar-type . ("=type=")))
'((:citar-title ("title") nil)
(:citar-author ("author" "editor") nil)
(:citar-date ("date" "year" "issued") nil)
(:citar-pages ("pages") nil)
(:citar-type ("=type=") nil)
(:citar-note ("note") nil))
"Field data to include in `org-roam' capture templates.
The `car' of each cons is the property symbol, and the `cdr' the
list of field names to use. When more than one, the value will
Expand Down Expand Up @@ -202,14 +203,13 @@ space."
(defun citar-org-roam--make-info-plist (citekey)
"Return org-roam capture template plist for CITEKEY."
(let ((infoplist))
(seq-do
(pcase-lambda (`(,capturevar . ,citarvars))
;; REVIEW do we only want to do this when non-nil?
(setq infoplist
(plist-put infoplist capturevar
(cdr (citar-get-field-with-value
citarvars citekey)))))
citar-org-roam-template-fields)
(seq-do
(pcase-lambda (`(,capturevar ,citarvars ,filter))
(let* ((rawstr (cdr (citar-get-field-with-value citarvars citekey)))
(fstr (if filter (apply filter rawstr) rawstr)))
(setq infoplist
(plist-put infoplist capturevar fstr))))
citar-org-roam-template-fields)
(setq infoplist
(plist-put infoplist :citar-citekey citekey))
infoplist))
Expand Down