branch: externals/org commit 54c4786d957daf6f9c9fbb914dc70b7e7f5a5b57 Author: Pedro A. Aranda <paag...@gmail.com> Commit: Ihor Radchenko <yanta...@posteo.net>
org-pcomplete: Factor out constant list of block keywords into variable * lisp/org-pcomplete.el (org-block-keywords): New constant. (pcomplete/org-mode/file-option): Use the new constatn. --- lisp/org-pcomplete.el | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index 8fdd968264..498a01da3c 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -157,6 +157,26 @@ The return value is a string naming the thing at point." (while (setq e (pop list)) (setq res (cons (downcase e) (cons (upcase e) res)))) (nreverse res))) + +;; Variables and constants + +(defconst org-block-keywords + (let (block-names) + (dolist (name + '("CENTER" "COMMENT" "EXAMPLE" "EXPORT" "QUOTE" "SRC" + "VERSE") + block-names) + (push (format "END_%s" name) block-names) + (push (concat "BEGIN_" + name + ;; Since language is compulsory in + ;; export blocks source blocks, add + ;; a space. + (and (member name '("EXPORT" "SRC")) " ")) + block-names) + (push (concat "ATTR_" name ": ") block-names)) + block-names) + "Keywords related to blocks.") ;;; Completion API @@ -219,20 +239,7 @@ When completing for #+STARTUP, for example, this function returns org-options-keywords) (mapcar (lambda (keyword) (concat keyword ": ")) org-element-affiliated-keywords) - (let (block-names) - (dolist (name - '("CENTER" "COMMENT" "EXAMPLE" "EXPORT" "QUOTE" "SRC" - "VERSE") - block-names) - (push (format "END_%s" name) block-names) - (push (concat "BEGIN_" - name - ;; Since language is compulsory in - ;; export blocks source blocks, add - ;; a space. - (and (member name '("EXPORT" "SRC")) " ")) - block-names) - (push (format "ATTR_%s: " name) block-names))) + org-block-keywords (mapcar (lambda (keyword) (concat keyword ": ")) (org-get-export-keywords)))) (substring pcomplete-stub 2)))