emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Unable to retrieve :parameters for src-block [org-element]


From: Kaushal Modi
Subject: [O] Unable to retrieve :parameters for src-block [org-element]
Date: Tue, 17 Oct 2017 12:51:22 +0000

Hello,

I am using the latest Org master.

I am trying to retrieving user-set parameters for a source block. While I am able to retrieve the :switches property for the src-block element, :parameters always returns as nil.

Here's a dummy version of the function I am using to parse source blocks in my custom exporter:

=====
(defun org-hugo-src-block (src-block _contents info)
  (let ((lang (org-element-property :language src-block))
        ;; See `org-element-src-block-parser' for all SRC-BLOCK properties.
        (switches (org-element-property :switches src-block))
        (parameters (org-element-property :parameters src-block))
        (number-lines (org-element-property :number-lines src-block))) ;Non-nil if -n or +n switch is used
    (message "ox-hugo src [dbg] number-lines: %S" number-lines)
    (message "ox-hugo src [dbg] switches: %S" switches)
    (message "ox-hugo src [dbg] parameters: %S" parameters)))
=====    

Here is the test Org snippet:

=====
#+BEGIN_SRC emacs-lisp -n :hl 1,3-4 :eval no
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
#+END_SRC
=====

(:hl 1,3-4 is something special that ox-hugo will handle.)

But on exporting that Org snippet, I get:

=====
ox-hugo src [dbg] number-lines: (new . 0)
ox-hugo src [dbg] switches: "-n"
ox-hugo src [dbg] parameters: nil
=====

If I put a debug statement directly in org-element-src-block-parser towards the end:

=====
;; SNIP
            (message "dbg: parameters: %s" parameters)
    (list 'src-block
  (nconc
   (list :language language
;; SNIP
=====

I get these in the *Messages*:

=====
dbg: parameters:  :hl 1,3-4 :eval no [3 times]
=====

So it is clear that the parameters are read inside org-element-src-block-parser, but I don't understand why (org-element-property :parameters src-block) is unable to fetch the same.

Hints?
--

Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]