summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-02-17 21:45:47 -0500
committerKyle Meyer <kyle@kyleam.com>2015-02-17 21:45:47 -0500
commit16b0cd1e44eb82d084f2238aec164f39e610d081 (patch)
tree8fed6b2c7d9607f508047d54701ab6e9d4d194ea
parent1e18ce377d133e14baab64483aa1b50a81a63c34 (diff)
downloadbog-16b0cd1e44eb82d084f2238aec164f39e610d081.tar.gz
Rewrite bog-list-orphan-citekeys
-rw-r--r--bog.el20
1 files changed, 9 insertions, 11 deletions
diff --git a/bog.el b/bog.el
index 92ed923..c5483a6 100644
--- a/bog.el
+++ b/bog.el
@@ -387,7 +387,7 @@ word constituents."
(-distinct citekeys)))
(defun bog-list-orphan-citekeys (&optional file)
- "List in citekeys that appear in notes but don't have heading.
+ "List citekeys that appear in notes but don't have a heading.
With prefix argument FILE, include only orphan citekeys from that
file."
(interactive (list (and current-prefix-arg
@@ -400,16 +400,14 @@ file."
(with-current-buffer (get-buffer-create bufname)
(erase-buffer)
(insert "\n")
- (-each files
- (lambda (f)
- (setq cks
- (--> (bog-non-heading-citekeys-in-file f)
- (-difference it heading-cks)
- (-sort (lambda (x y) (string-lessp x y)) it)
- (mapconcat #'identity it "\n")))
- (unless (equal cks "")
- (insert (format "* %s\n\n" (file-name-nondirectory f)))
- (insert (concat cks "\n\n")))))
+ (dolist (file files)
+ (let* ((text-cks (bog-non-heading-citekeys-in-file file))
+ (nohead-cks (sort (-difference text-cks heading-cks)
+ #'string-lessp)))
+ (when nohead-cks
+ (insert (format "* %s\n\n%s\n\n"
+ (file-name-nondirectory file)
+ (mapconcat #'identity nohead-cks "\n"))))))
(org-mode)
(bog-mode 1)
(show-all)