all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Unable to retrieve :parameters for src-block [org-element]
@ 2017-10-17 12:51 Kaushal Modi
  2017-10-17 15:45 ` Kaushal Modi
  2017-10-17 16:31 ` Berry, Charles
  0 siblings, 2 replies; 7+ messages in thread
From: Kaushal Modi @ 2017-10-17 12:51 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1924 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3055 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-18 23:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-17 12:51 Unable to retrieve :parameters for src-block [org-element] Kaushal Modi
2017-10-17 15:45 ` Kaushal Modi
2017-10-17 16:31 ` Berry, Charles
2017-10-17 17:22   ` Kaushal Modi
2017-10-17 21:39     ` Berry, Charles
2017-10-18 21:20       ` Kaushal Modi
2017-10-18 23:19         ` Kaushal Modi

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.