pcomplete: improve header arguments completion

* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src): Make it
complete all available header arguments.

* testing/lisp/test-org-pcomplete.el (test-org-pcomplete/src-block):
New test.
This commit is contained in:
stardiviner 2020-05-12 21:44:04 +08:00 committed by Nicolas Goaziou
parent cd2b108d22
commit 1abf4f600a
2 changed files with 26 additions and 5 deletions

View File

@ -418,11 +418,17 @@ switches."
(symbol-plist
'org-babel-load-languages)
'custom-type)))))))
(while (pcomplete-here
'("-n" "-r" "-l"
":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
":session" ":shebang" ":tangle" ":tangle-mode" ":var"))))
(let* ((info (org-babel-get-src-block-info 'light))
(lang (car info))
(lang-headers (intern (concat "org-babel-header-args:" lang)))
(headers (org-babel-combine-header-arg-lists
org-babel-common-header-args-w-values
(and (boundp lang-headers) (eval lang-headers t)))))
(while (pcomplete-here
(append (mapcar
(lambda (arg) (format ":%s" (symbol-name (car arg))))
headers)
'("-n" "-r" "-l"))))))
(defun pcomplete/org-mode/block-option/clocktable ()
"Complete keywords in a clocktable line."

View File

@ -75,6 +75,21 @@
(buffer-string))
t)))
(ert-deftest test-org-pcomplete/src-block ()
"Test Babel source block header arguments completion."
(should
(string-prefix-p
"#+begin_src emacs-lisp"
(org-test-with-temp-text "#+begin_src emac<point>"
(pcomplete)
(buffer-string))))
(should
(string-prefix-p
"#+begin_src emacs-lisp :session"
(org-test-with-temp-text "#+begin_src emacs-lisp :sess<point>"
(pcomplete)
(buffer-string)))))
(ert-deftest test-org-pcomplete/link ()
"Test link completion"
(should