all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Unable to retrieve :parameters for src-block [org-element]
Date: Tue, 17 Oct 2017 12:51:22 +0000	[thread overview]
Message-ID: <CAFyQvY17+XnrFvuq05NzCc5FPnJxnOBEjXkAia=c9fv0qHNPbA@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2017-10-17 12:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 12:51 Kaushal Modi [this message]
2017-10-17 15:45 ` Unable to retrieve :parameters for src-block [org-element] 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

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

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

  git send-email \
    --in-reply-to='CAFyQvY17+XnrFvuq05NzCc5FPnJxnOBEjXkAia=c9fv0qHNPbA@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.