summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-03-06 01:22:32 -0500
committerKyle Meyer <kyle@kyleam.com>2016-03-06 01:22:32 -0500
commit3443b74c66f2a01b79c7322b3908ae797b6bda1b (patch)
treea1405ced437e2870e222231813c51f5eae16289d
parent51d956233c747e93a5fb2aabafd9e3d09666b904 (diff)
downloadbog-3443b74c66f2a01b79c7322b3908ae797b6bda1b.tar.gz
Add command to list orphan bibs
-rw-r--r--NEWS1
-rw-r--r--bog.el20
2 files changed, 21 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 64b905c..6cdbe4b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Bog NEWS -- history of user-visible changes -*- mode: org; -*-
** New features
+- New command ~bog-list-orphan-files~.
- New command ~bog-dired-jump-to-citekey-file~.
* v1.1.0
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