update packages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
;;; org-bibtex-extras --- extras for working with org-bibtex entries
|
||||
;;; org-bibtex-extras --- extras for working with org-bibtex entries -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
|
||||
|
||||
@@ -63,14 +63,22 @@
|
||||
|
||||
(declare-function org-trim "org" (s &optional keep-lead))
|
||||
|
||||
(defcustom obe-bibtex-file nil "File holding bibtex entries.")
|
||||
(defgroup org-bibtex-extras nil
|
||||
"Extras for working with org-bibtex entries."
|
||||
:group 'org-bibtex)
|
||||
|
||||
(defcustom obe-bibtex-file nil
|
||||
"File holding bibtex entries."
|
||||
:type 'file
|
||||
:group 'org-bibtex-extras)
|
||||
|
||||
(defcustom obe-html-link-base nil
|
||||
"Base of citation links.
|
||||
For example, to point to your `obe-bibtex-file' use the following.
|
||||
|
||||
(setq obe-html-link-base (format \"file:%s\" obe-bibtex-file))
|
||||
")
|
||||
(setq obe-html-link-base (format \"file:%s\" obe-bibtex-file))"
|
||||
:type 'string
|
||||
:group 'org-bibtex-extras)
|
||||
|
||||
(defvar obe-citations nil)
|
||||
(defun obe-citations ()
|
||||
@@ -96,42 +104,43 @@ For example, to point to your `obe-bibtex-file' use the following.
|
||||
(mapcar #'org-trim
|
||||
(split-string (match-string 1) ",")) ", "))))))
|
||||
|
||||
(defun obe-meta-to-json (meta &optional fields)
|
||||
"Turn a list of META data from citations into a string of json."
|
||||
(let ((counter 1) nodes links)
|
||||
(flet ((id (it) (position it nodes :test #'string= :key #'car))
|
||||
(col (k) (mapcar (lambda (r) (cdr (assoc k r))) meta))
|
||||
(add (lst)
|
||||
(dolist (el lst) (push (cons el counter) nodes))
|
||||
(cl-incf counter)))
|
||||
;; build the nodes of the graph
|
||||
(add (col :title))
|
||||
(add (cl-remove-if (lambda (author) (string-match "others" author))
|
||||
(remove-duplicates (apply #'append (col :authors))
|
||||
:test #'string=)))
|
||||
(dolist (field fields)
|
||||
(add (remove-duplicates (col field) :test #'string=)))
|
||||
;; build the links in the graph
|
||||
(dolist (citation meta)
|
||||
(let ((dest (id (cdr (assq :title citation)))))
|
||||
(dolist (author (mapcar #'id (cdr (assq :authors citation))))
|
||||
(when author (push (cons author dest) links)))
|
||||
(let ((jid (id (cdr (assq :journal citation)))))
|
||||
(when jid (push (cons jid dest) links)))
|
||||
(let ((cid (id (cdr (assq :category citation)))))
|
||||
(when cid (push (cons cid dest) links)))))
|
||||
;; build the json string
|
||||
(format "{\"nodes\":[%s],\"links\":[%s]}"
|
||||
(mapconcat
|
||||
(lambda (pair)
|
||||
(format "{\"name\":%S,\"group\":%d}"
|
||||
(car pair) (cdr pair)))
|
||||
nodes ",")
|
||||
(mapconcat
|
||||
(lambda (link)
|
||||
(format "{\"source\":%d,\"target\":%d,\"value\":1}"
|
||||
(car link) (cdr link)))
|
||||
(meta-to-links meta nodes) ",")))))
|
||||
;; FIXME: `meta-to-links' is not a known function.
|
||||
;; (defun obe-meta-to-json (meta &optional fields)
|
||||
;; "Turn a list of META data from citations into a string of json."
|
||||
;; (let ((counter 1) nodes links)
|
||||
;; (cl-flet ((id (it) (cl-position it nodes :test #'string= :key #'car))
|
||||
;; (col (k) (mapcar (lambda (r) (cdr (assoc k r))) meta))
|
||||
;; (add (lst)
|
||||
;; (dolist (el lst) (push (cons el counter) nodes))
|
||||
;; (cl-incf counter)))
|
||||
;; ;; build the nodes of the graph
|
||||
;; (add (col :title))
|
||||
;; (add (cl-remove-if (lambda (author) (string-match "others" author))
|
||||
;; (cl-remove-duplicates (apply #'append (col :authors))
|
||||
;; :test #'string=)))
|
||||
;; (dolist (field fields)
|
||||
;; (add (cl-remove-duplicates (col field) :test #'string=)))
|
||||
;; ;; build the links in the graph
|
||||
;; (dolist (citation meta)
|
||||
;; (let ((dest (id (cdr (assq :title citation)))))
|
||||
;; (dolist (author (mapcar #'id (cdr (assq :authors citation))))
|
||||
;; (when author (push (cons author dest) links)))
|
||||
;; (let ((jid (id (cdr (assq :journal citation)))))
|
||||
;; (when jid (push (cons jid dest) links)))
|
||||
;; (let ((cid (id (cdr (assq :category citation)))))
|
||||
;; (when cid (push (cons cid dest) links)))))
|
||||
;; ;; build the json string
|
||||
;; (format "{\"nodes\":[%s],\"links\":[%s]}"
|
||||
;; (mapconcat
|
||||
;; (lambda (pair)
|
||||
;; (format "{\"name\":%S,\"group\":%d}"
|
||||
;; (car pair) (cdr pair)))
|
||||
;; nodes ",")
|
||||
;; (mapconcat
|
||||
;; (lambda (link)
|
||||
;; (format "{\"source\":%d,\"target\":%d,\"value\":1}"
|
||||
;; (car link) (cdr link)))
|
||||
;; (meta-to-links meta nodes) ",")))))
|
||||
|
||||
(provide 'org-bibtex-extras)
|
||||
;;; org-bibtex-extras ends here
|
||||
|
||||
Reference in New Issue
Block a user