emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: stardiviner <numbchild@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [RFC] Let Org Mode's completion support all Babel header arguments
Date: Wed, 13 May 2020 17:40:19 +0800	[thread overview]
Message-ID: <87lflwuq9o.fsf@gmail.com> (raw)
In-Reply-To: <87imh1tdy1.fsf@nicolasgoaziou.fr>


[-- Attachment #1.1: Type: text/plain, Size: 1667 bytes --]


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> Subject: [PATCH] org-pcomplete.el: improve header arguments completion
>
> Thank you. Some comments follow.
>
>> -  (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
>> +		   (when (boundp lang-headers) (eval lang-headers t)))))
>
> (when ...)  -> (and (bounp lang-headers)) (symbol-value lang-headers)

Done.

>
>> +    (while (pcomplete-here
>> +	    (mapcar
>> +             (lambda (arg) (concat ":" (symbol-name (car arg))))
>
> (concat ...) -> (format ":%s" (car arg))

Fixed

>
>> +	     headers)))))
>
> It looks like you dropped the switches "-n", "-r", "-l".
>
> Also, could you add a few tests in "test-org-pcomplete.el"?

Add a test for Babel src block languages and header arguments.

I'm wandering how to complete header argument values? Do you have any hints?

>
> Regards,


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org-pcomplete.el-improve-header-arguments-completion.patch --]
[-- Type: text/x-patch, Size: 2583 bytes --]

From 70232e4b1798725d81edab1dfd7984d41d120e0e Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Tue, 12 May 2020 21:44:04 +0800
Subject: [PATCH] org-pcomplete.el: improve header arguments completion

* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src): Make it
complete real all available header arguments like command
`org-babel-insert-header-arg'.
---
 lisp/org-pcomplete.el              | 16 +++++++++++-----
 testing/lisp/test-org-pcomplete.el | 17 +++++++++++++++++
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 28b40fadd..65651512a 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -418,11 +418,17 @@ (defun pcomplete/org-mode/block-option/src ()
 				    (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."
diff --git a/testing/lisp/test-org-pcomplete.el b/testing/lisp/test-org-pcomplete.el
index e6b0e8a7e..4a7184100 100644
--- a/testing/lisp/test-org-pcomplete.el
+++ b/testing/lisp/test-org-pcomplete.el
@@ -75,6 +75,23 @@ (ert-deftest test-org-pcomplete/keyword ()
       (buffer-string))
     t)))
 
+(ert-deftest test-org-pcomplete/src-block ()
+  "Test Babel src block header arguments completion."
+  (should
+   (string-prefix-p
+    "#+begin_src emacs-lisp"
+    (org-test-with-temp-text "#+begin_src emac<point>"
+      (pcomplete)
+      (buffer-string))
+    t))
+  (should
+   (string-prefix-p
+    "#+begin_src emacs-lisp :session"
+    (org-test-with-temp-text "#+begin_src emacs-lisp :sess<point>"
+      (pcomplete)
+      (buffer-string))
+    t)))
+
 (ert-deftest test-org-pcomplete/link ()
   "Test link completion"
   (should
-- 
2.26.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 515 bytes --]

  reply	other threads:[~2020-05-13  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-09  7:33 stardiviner
2020-05-10 12:35 ` Nicolas Goaziou
2020-05-12 13:48   ` stardiviner
2020-05-12 14:39     ` Nicolas Goaziou
2020-05-13  9:40       ` stardiviner [this message]
2020-05-13 17:04         ` Nicolas Goaziou
2020-05-14  4:05           ` stardiviner
2020-05-14 12:59             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lflwuq9o.fsf@gmail.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --subject='Re: [RFC] Let Org Mode'\''s completion support all Babel header arguments' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).