From 1a62cd94cfc92c3ce6eadb2ffc1d6a18e8caee86 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 7 Oct 2022 15:49:46 +0800 Subject: [PATCH] org-pcomplete: Fix completion inside bracketed link * lisp/org-pcomplete.el (pcomplete/org-mode/searchhead): Drop closing brackets when completing inside bracketed link [[*head]]. Reported-by: Carlos Pita Link: https://orgmode.org/list/87r1cfvvd0.fsf@localhost --- lisp/org-pcomplete.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index b4f5f67ed..225cdc093 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -364,7 +364,11 @@ This needs more work, to handle headings with lots of spaces in them." (pcomplete-uniquify-list tbl))) ;; When completing a bracketed link, i.e., "[[*", argument ;; starts at the star, so remove this character. - (substring pcomplete-stub 1)))) + ;; Also, if the completion is done inside [[*head]], + ;; drop the closing parentheses. + (replace-regexp-in-string + "\\]+$" "" + (substring pcomplete-stub 1))))) (defun pcomplete/org-mode/tag () "Complete a tag name. Omit tags already set."