From 3443b74c66f2a01b79c7322b3908ae797b6bda1b Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 6 Mar 2016 01:22:32 -0500 Subject: Add command to list orphan bibs --- bog.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bog.el') diff --git a/bog.el b/bog.el index f5123fc..41cc99d 100644 --- a/bog.el +++ b/bog.el @@ -914,6 +914,26 @@ instead of citekeys from file names in `bog-bib-directory'." (lambda (dir) (directory-files dir nil ".*\\.bib$" t)) dirs))))))) +;;;###autoload +(defun bog-list-orphan-bibs () + "Find bib citekeys that don't have a citekey heading." + (interactive) + (let ((orphans (bog--set-difference (bog-bib-citekeys) + (bog-all-heading-citekeys))) + (orphan-bufname "*Bog orphan bibs*")) + (if orphans + (with-current-buffer (get-buffer-create orphan-bufname) + (erase-buffer) + (setq default-directory bog-root-directory) + (insert ?\n) + (insert (mapconcat #'identity orphans "\n")) + (goto-char (point-min)) + (org-mode) + (pop-to-buffer (current-buffer))) + (let ((old-buf (get-buffer-create orphan-bufname))) + (when old-buf + (kill-buffer old-buf))) + (message "No orphans found")))) ;;; Web -- cgit v1.2.3