---------- Forwarded message --------- From: Pedro Andres Aranda Gutierrez <paag...@gmail.com> Date: Mon, 7 Apr 2025 at 17:20 Subject: [PATCH] Small speed-up for org-pcomplete.el To: <org-m...@gnu.org>, Ihor Radchenko <yanta...@posteo.net>
Hi Since the block keywords are always the same, why not put them in a variable. Plus add the LATEX keywords, which seem not to want to appear in pcomplete -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Sagen's Paradeiser, write BE! Year 1 of the New Koprocracy -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Sagen's Paradeiser, write BE! Year 1 of the New Koprocracy
From 5dc293565702525424605c74338d389168d0dce0 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <paaguti@gmail.com> Date: Mon, 7 Apr 2025 16:50:15 +0200 Subject: [PATCH] Make block keywords a variable and add LaTeX keywords to pcomplete * lisp/pcomplete: Create the keywords list only once and store it in the variable org-block-keywords, don't create it for every call to (pcomplete/org-mode/file-option). Do the same for the LaTeX keywords. --- etc/ORG-NEWS | 4 ++++ lisp/org-pcomplete.el | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 982bac4e9..6277f08cc 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -587,6 +587,10 @@ will be defined as empty and not produce any metadata if their corresponding ~org-latex-with-author~, ~org-latex-with-title~, or ~org-latex-with-creator~ option is set to ~nil~. +*** LaTeX keywords are included in pcomplete + +~#+LATEX_...:~ keywords are now offered by ~pcomplete~ when needed. + * Version 9.7 ** Important announcements and breaking changes diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index 8fdd96826..4af7513b7 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -157,6 +157,30 @@ 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))) + +;; +(defvar org-latex-keywords + '("LATEX_CLASS: " "LATEX_CLASS_OPTIONS: " "LATEX_COMPILER: " + "LATEX_HEADER: " "LATEX_HEADER_EXTRA: ") + "The #+... keywords defined in ox-latex.el") + +(defvar 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) + "The keywords related with the blocks") ;;; Completion API @@ -219,20 +243,8 @@ 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-latex-keywords + org-block-keywords (mapcar (lambda (keyword) (concat keyword ": ")) (org-get-export-keywords)))) (substring pcomplete-stub 2))) -- 2.34.1