Merge branch 'master' into next

This commit is contained in:
Nicolas Goaziou 2018-11-25 02:03:14 +01:00
commit 86a6087f92
2 changed files with 40 additions and 5 deletions

View File

@ -104,10 +104,11 @@ The return value is a string naming the thing at point."
(char-before))) (char-before)))
(cons "tex" nil)) (cons "tex" nil))
;; Tags on a headline. ;; Tags on a headline.
((and (org-at-heading-p) ((and (org-match-line
(eq ?: (save-excursion (format "\\*+ \\(?:.+? \\)?\\(:\\)\\(\\(?::\\|%s\\)+\\)?[ \t]*$"
(skip-chars-backward "[:alnum:]_@#%") org-tag-re))
(char-before)))) (or (org-point-in-group (point) 2)
(= (point) (match-end 1))))
(cons "tag" nil)) (cons "tag" nil))
;; TODO keywords on an empty headline. ;; TODO keywords on an empty headline.
((and (string-match "^\\*+ +\\S-*$" line-to-here) ((and (string-match "^\\*+ +\\S-*$" line-to-here)
@ -372,7 +373,8 @@ This needs more work, to handle headings with lots of spaces in them."
(setq lst (delete tag lst))) (setq lst (delete tag lst)))
lst)) lst))
(and (string-match ".*:" pcomplete-stub) (and (string-match ".*:" pcomplete-stub)
(substring pcomplete-stub (match-end 0)))))) (substring pcomplete-stub (match-end 0)))
t)))
(defun pcomplete/org-mode/drawer () (defun pcomplete/org-mode/drawer ()
"Complete a drawer name, including \"PROPERTIES\"." "Complete a drawer name, including \"PROPERTIES\"."

View File

@ -125,6 +125,39 @@
(pcomplete) (pcomplete)
(buffer-string))))) (buffer-string)))))
(ert-deftest test-org-pcomplete/tag ()
"Test tag completion."
;; Complete at end of line, according to `org-current-tag-alist'.
(should
(equal "* H :foo:"
(org-test-with-temp-text "* H :<point>"
(let ((org-current-tag-alist '(("foo")))) (pcomplete))
(buffer-string))))
(should
(equal "* H :foo:bar:"
(org-test-with-temp-text "* H :foo:b<point>"
(let ((org-current-tag-alist '(("bar")))) (pcomplete))
(buffer-string))))
;; If `org-current-tag-alist' is non-nil, complete against tags in
;; buffer.
(should
(equal "* H1 :bar:\n* H2 :bar:"
(org-test-with-temp-text "* H1 :bar:\n* H2 :<point>"
(let ((org-current-tag-alist nil)) (pcomplete))
(buffer-string))))
;; Do not complete in the middle of a line.
(should
(equal "* H :notag: :real:tags:"
(org-test-with-temp-text "* H :notag:<point> :real:tags:"
(let ((org-current-tag-alist '(("foo")))) (pcomplete))
(buffer-string))))
;; Complete even when there's a match on the line.
(should
(equal "* foo: :foo:"
(org-test-with-temp-text "* foo: :<point>"
(let ((org-current-tag-alist '(("foo")))) (pcomplete))
(buffer-string)))))
(ert-deftest test-org-pcomplete/todo () (ert-deftest test-org-pcomplete/todo ()
"Test TODO completion." "Test TODO completion."
(should (should