From 45a6863e074f049489a2b9fa94f14635bcce4788 Mon Sep 17 00:00:00 2001 From: ParetoOptimalDev Date: Sun, 25 Dec 2022 12:39:30 -0600 Subject: [PATCH] (completions): don't complete org-roam nodes in source blocks (#2292) * don't complete org-roam nodes in source blocks This fixes the following situation where `org-roam-completion-everywhere = t` and you are working with org-babel blocks in one of your org-roam nodes. ``` ``` Before my nodes would be suggested, but after this change only valid babel headers are suggested as desired. Previously completions from org-roam nodes would be suggested * fix lints Co-authored-by: Jethro Kuan --- org-roam-node.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org-roam-node.el b/org-roam-node.el index 7614e67..7239bda 100644 --- a/org-roam-node.el +++ b/org-roam-node.el @@ -770,7 +770,8 @@ We use this as a substitute for `org-link-bracket-re', because "Complete \"roam:\" link at point to an existing Org-roam node." (let (roam-p start end) (when (org-in-regexp org-roam-bracket-completion-re 1) - (setq roam-p (not (string-blank-p (match-string 1))) + (setq roam-p (not (or (org-in-src-block-p) + (string-blank-p (match-string 1)))) start (match-beginning 2) end (match-end 2)) (list start end @@ -792,6 +793,7 @@ outside of the bracket syntax for links (i.e. \"[[roam:|]]\"), hence \"everywhere\"." (when (and org-roam-completion-everywhere (thing-at-point 'word) + (not (org-in-src-block-p)) (not (save-match-data (org-in-regexp org-link-any-re)))) (let ((bounds (bounds-of-thing-at-point 'word))) (list (car bounds) (cdr bounds)