[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 97951352bb: Fix [[* completion when there is text a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 97951352bb: Fix [[* completion when there is text after point |
Date: |
Sun, 7 Jan 2024 12:58:22 -0500 (EST) |
branch: externals/org
commit 97951352bb4a32b06f0dede37cf5f796ad3f14c2
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
Fix [[* completion when there is text after point
* lisp/org-pcomplete.el (org-parse-arguments): Parse text between [[*
and point as a single "argument" for pcomplete. This avoid weird
breakage when treating every space-separated text in the line as an
argument.
(pcomplete/org-mode/searchhead): Do not alter `pcomplete-stub' - it is
no longer necessary as `org-parse-arguments' now takes care about not
including * and ] into the stub.
Warning! pcomplete code is rather tricky and it is not always clear if
Org's approach is not overusing internals of pcomplete.
Reported-by: Ignacio Casso <ignaciocasso@hotmail.com>
Link: https://orgmode.org/list/87ils0lut8.fsf@localhost
---
lisp/org-pcomplete.el | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index f10920f440..f1bc34966d 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -176,21 +176,29 @@ When completing for #+STARTUP, for example, this function
returns
(defun org-parse-arguments ()
"Parse whitespace separated arguments in the current region."
- (let ((begin (line-beginning-position))
- (end (line-end-position))
- begins args)
- (save-restriction
- (narrow-to-region begin end)
+ (if (equal (cons "searchhead" nil) (org-thing-at-point))
+ ;; [[* foo<point> bar link::search option.
+ ;; Arguments are not simply space-separated.
(save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (skip-chars-forward " \t\n[")
- (setq begins (cons (point) begins))
- (skip-chars-forward "^ \t\n[")
- (setq args (cons (buffer-substring-no-properties
- (car begins) (point))
- args)))
- (cons (reverse args) (reverse begins))))))
+ (let ((origin (point)))
+ (skip-chars-backward "^*" (line-beginning-position))
+ (cons (list (buffer-substring-no-properties (point) origin))
+ (list (point)))))
+ (let ((begin (line-beginning-position))
+ (end (line-end-position))
+ begins args)
+ (save-restriction
+ (narrow-to-region begin end)
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (skip-chars-forward " \t\n[")
+ (setq begins (cons (point) begins))
+ (skip-chars-forward "^ \t\n[")
+ (setq args (cons (buffer-substring-no-properties
+ (car begins) (point))
+ args)))
+ (cons (reverse args) (reverse begins)))))))
(defun org-pcomplete-initial ()
"Call the right completion function for first argument completions."
@@ -366,14 +374,7 @@ This needs more work, to handle headings with lots of
spaces in them."
;; Remove the leading asterisk from
;; `org-link-heading-search-string' result.
(push (substring (org-link-heading-search-string) 1) tbl))
- (pcomplete-uniquify-list tbl)))
- ;; When completing a bracketed link, i.e., "[[*", argument
- ;; starts at the star, so remove this character.
- ;; Also, if the completion is done inside [[*head<point>]],
- ;; drop the closing parentheses.
- (replace-regexp-in-string
- "\\]+$" ""
- (substring pcomplete-stub 1)))))
+ (pcomplete-uniquify-list tbl))))))
(defun pcomplete/org-mode/tag ()
"Complete a tag name. Omit tags already set."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org 97951352bb: Fix [[* completion when there is text after point,
ELPA Syncer <=