From: Kaushal Modi <kaushal.modi@gmail.com>
To: "Berry, Charles" <ccberry@ucsd.edu>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Unable to retrieve :parameters for src-block [org-element]
Date: Wed, 18 Oct 2017 21:20:04 +0000 [thread overview]
Message-ID: <CAFyQvY1k1UG7=6M8FjmaVzibwo4pDHb3EegxwPD3gOtto2Hg5g@mail.gmail.com> (raw)
In-Reply-To: <B1285E6E-07FE-41C3-9A93-64C99BC67569@ucsd.edu>
[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]
On Tue, Oct 17, 2017 at 5:39 PM Berry, Charles <ccberry@ucsd.edu> wrote:
> I think this might work: Add `after' advice to `org-babel-exp-code' that
> copies the header args you want to retain and prepends a #+header: line
> with them to the string returned by org-babel-exp-code. Then your
> src-block transcoder can find them.
>
Thanks, TIL about org-babel-exp-code.
Thanks for the instructions, below works perfectly!
=====
(defun org-babel-exp-code--retain (orig-fun &rest args)
"Return the original code block formatted for export."
(let* ((param-keys-to-be-retained '(:hl_lines :foo)) ;Example of keys
whose conses need to be retained
(info (car args))
(parameters (nth 2 info))
(ox-hugo-params-str (let ((str ""))
(dolist (param parameters)
(dolist (retain-key
param-keys-to-be-retained)
(when (equal retain-key (car param))
(setq str (concat str " "
(symbol-name
retain-key) " "
(cdr param))))))
(org-string-nw-p (org-trim str))))
ret)
(setq ret (apply orig-fun args)) ;Original return value
(when ox-hugo-params-str
(setq ret (replace-regexp-in-string "\\`#\\+BEGIN_SRC .*" (format
"\\& %s" ox-hugo-params-str) ret)))
ret))
(advice-add 'org-babel-exp-code :around #'org-babel-exp-code--retain)
=====
Test:
=====
#+BEGIN_SRC emacs-lisp :eval no-export :results output silent :hl_lines
1,3-4 :foo bar
(message "foo")
#+END_SRC
=====
The messages based on the debug code I pasted earlier in this thread now
look like:
=====
[src-block dbg] number-lines: nil
[src-block dbg] switches: nil
[src-block dbg] parameters: ":foo bar :hl_lines 1,3-4"
=====
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 3024 bytes --]
next prev parent reply other threads:[~2017-10-18 21:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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='CAFyQvY1k1UG7=6M8FjmaVzibwo4pDHb3EegxwPD3gOtto2Hg5g@mail.gmail.com' \
--to=kaushal.modi@gmail.com \
--cc=ccberry@ucsd.edu \
--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 public 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).