mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 22:37:47 +00:00
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
This commit is contained in:
parent
aab2c94531
commit
97951352bb
|
@ -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."
|
||||
|
|
Loading…
Reference in a new issue