Do not output headlines without backlinks in dynamic blocks

This commit is contained in:
Daniel - 2022-05-20 19:09:39 +02:00
parent 99dbd00e71
commit c572451c14
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 10 additions and 10 deletions

View File

@ -1046,16 +1046,16 @@ PARAMS may contain the following values:
;; Formatting.
(insert (format "| Item | Backlinks | Priority |\n|---|"))
(dolist (headline headlines)
(insert (format "\n| %s |\n|---|" (db/org--format-link-with-headline (car headline))))
(let ((backlink-lines (-> (mapcar #'(lambda (backlink-id)
(list (db/org--format-link-with-headline backlink-id)
(org-entry-get (org-id-find backlink-id 'marker)
"PRIORITY")))
(cdr headline))
(cl-sort #'string< :key #'cl-second))))
(dolist (line backlink-lines)
(insert (apply #'format "\n| | %s | %s |" line)))
(when backlink-lines ; only print closing hline when there's something to close
(when (cdr headline) ; do not print backlinks if there are none
(insert (format "\n| %s |\n|---|" (db/org--format-link-with-headline (car headline))))
(let ((backlink-lines (-> (mapcar #'(lambda (backlink-id)
(list (db/org--format-link-with-headline backlink-id)
(org-entry-get (org-id-find backlink-id 'marker)
"PRIORITY")))
(cdr headline))
(cl-sort #'string< :key #'cl-second))))
(dolist (line backlink-lines)
(insert (apply #'format "\n| | %s | %s |" line)))
(insert "\n|---|"))))
(org-table-align)))