summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-12-30 18:06:05 -0500
committerKyle Meyer <kyle@kyleam.com>2015-12-30 18:06:05 -0500
commita10e67dbfff0df878fc4b3b0f0b690afc1fbfc8d (patch)
tree426ee81dc02bcec2b7acb857aa50857dd973b906
parentdf93878aa8c590579774593b747a5000cbb35c42 (diff)
downloadbog-a10e67dbfff0df878fc4b3b0f0b690afc1fbfc8d.tar.gz
Add command to find files with no heading citekey
-rw-r--r--NEWS3
-rw-r--r--bog.el24
2 files changed, 27 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 3cc18af..cff6477 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@
** New features
+- New command ~bog-list-orphan-files~ finds citekey files that don't
+ have a corresponding citekey heading in the notes.
+
- New command ~bog-rename-citekey-file~ updates the name of an
existing citekey file.
diff --git a/bog.el b/bog.el
index 64b5ab9..05b78bb 100644
--- a/bog.el
+++ b/bog.el
@@ -730,6 +730,30 @@ Generate a file name with the form
(directory-files bog-stage-directory
t directory-files-no-dot-files-regexp)))
+;;;###autoload
+(defun bog-list-orphan-files ()
+ "Find files in `bog-file-directory' without a citekey heading."
+ (interactive)
+ (let ((head-cks (bog-all-heading-citekeys)))
+ (with-current-buffer (get-buffer-create "*Bog orphan files*")
+ (erase-buffer)
+ (setq default-directory bog-root-directory)
+ (insert ?\n)
+ (dolist (ck-file (bog-all-citekey-files))
+ (let ((base-name (file-name-nondirectory ck-file))
+ (case-fold-search nil))
+ (unless (and (string-match (concat "\\`" bog-citekey-format)
+ base-name)
+ (member (match-string-no-properties 0 base-name)
+ head-cks))
+ (insert (format "- [[file:%s]]\n" (file-relative-name ck-file))))))
+ (goto-char (point-min))
+ (org-mode)
+ (if (/= (buffer-size) 1)
+ (pop-to-buffer (current-buffer))
+ (message "No orphans found")
+ (kill-buffer)))))
+
;;; BibTeX-related