Browse Source

org-pcomplete: Fix completion inside bracketed link

* lisp/org-pcomplete.el (pcomplete/org-mode/searchhead): Drop closing
brackets when completing inside bracketed link [[*head<point>]].

Reported-by: Carlos Pita <carlosjosepita2@gmail.com>
Link: https://orgmode.org/list/87r1cfvvd0.fsf@localhost
Ihor Radchenko 2 years ago
parent
commit
1a62cd94cf
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lisp/org-pcomplete.el

+ 5 - 1
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<point>]],
+          ;; 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."