From 96638b09e445307df56794d273f8200eba65e0c2 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 27 Mar 2021 10:39:53 +0100 Subject: [PATCH] Allow to show backlinks directly from Org agenda buffers This is more convenient than to first switch to the item in the corrsponding Org mode buffer and then querying for its backlinks. --- site-lisp/db-org.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 583aee8..3a208b0 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -704,14 +704,21 @@ linking to any item." "Find links to current item. Only links using the ID or CUSTOM_ID property are considered. -If ARG is given, or if not in an Org Mode buffer, interactively -prompt for an item." +If ARG is given, or if neither in an Org Mode buffer nor on a +headline in an Org Agenda buffer, interactively prompt for an +item." (interactive "P") (apply #'db/org-find-items-linking-by-id - (if (and (derived-mode-p 'org-mode) (not arg)) - (list (org-id-get) (org-entry-get nil "CUSTOM_ID")) - (org-with-point-at (db/org--get-location) - (list (org-id-get) (org-entry-get nil "CUSTOM_ID")))))) + (cond ((and (not arg) (derived-mode-p 'org-mode)) + (list (org-id-get) (org-entry-get nil "CUSTOM_ID"))) + ((and (not arg) + (derived-mode-p 'org-agenda-mode) + (org-get-at-bol 'org-hd-marker)) + (org-with-point-at (org-get-at-bol 'org-hd-marker) + (list (org-id-get) (org-entry-get nil "CUSTOM_ID")))) + (t + (org-with-point-at (db/org--get-location) + (list (org-id-get) (org-entry-get nil "CUSTOM_ID"))))))) (defun db/org-add-link-to-other-item (arg) "Interactively query for item and add link to it at point.