emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: [RFC] [PATCH] [babel] read description lists as lists of lists
Date: Fri, 19 Sep 2014 15:17:54 -0400	[thread overview]
Message-ID: <87ha03qv19.fsf@gmail.com> (raw)

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


Hello all,

The attached patch makes babel read description lists as lists of the
following format: (("term" "description") ...).  The present default is
to simply read in the text of each list item, yielding:
("term :: description" ...).

Of course, it’s possible to interconvert between the two formats, but I
think the greater structure of this proposal makes things easier for
babel authors.  (Another way of thinking of the proposal is that it
treats description lists like two-column tables.)

What do people think?

Thanks,

-- 
Aaron Ecay

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core.el-Read-description-lists-as-lisp-lists.patch --]
[-- Type: text/x-diff, Size: 1577 bytes --]

From a7e01675f2c89fb648e528c3efe535ed0b2389f1 Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Fri, 19 Sep 2014 14:39:26 -0400
Subject: [PATCH] ob-core.el: Read description lists as lisp lists.

* lisp/ob-core.el (org-babel-read-list): Read description lists as
lisp lists.

This allows description lists to be used as structured input to a
babel block.
---
 lisp/ob-core.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index e01c4d2..f1661cb 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2035,9 +2035,21 @@ following the source block."
           (org-table-to-lisp)))
 
 (defun org-babel-read-list ()
-  "Read the list at `point' into emacs-lisp."
-  (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval))
-	  (mapcar #'cadr (cdr (org-list-parse-list)))))
+  "Read the list at `point' into emacs-lisp.
+
+The result is a list of strings \(the list items), unless the
+input list is a description list.  In that case, the result will
+be a list of lists; each of the latter lists will have two
+elements: the term and the description."
+  (let* ((parsed (org-list-parse-list))
+	 (elements (mapcar #'cadr (cdr parsed))))
+    (if (eq (car parsed) 'descriptive)
+	(mapcar (lambda (el)
+		  (let ((s (split-string el " :: ")))
+		    (list (nth 0 s) (mapconcat #'identity (cdr s) " :: "))))
+		elements)
+      (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval))
+	      elements))))
 
 (defvar org-link-types-re)
 (defun org-babel-read-link ()
-- 
2.1.0


             reply	other threads:[~2014-09-19 19:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19 19:17 Aaron Ecay [this message]
2014-09-20  0:30 ` [RFC] [PATCH] [babel] read description lists as lists of lists Charles Berry
2014-09-20 11:52 ` Nicolas Goaziou
2014-09-23  4:02   ` Aaron Ecay
2014-09-24 19:56     ` Nicolas Goaziou
2014-09-24 22:49       ` Aaron Ecay
2014-09-26  9:03         ` Nicolas Goaziou
2014-09-28  5:55           ` Aaron Ecay
2014-09-28 10:49             ` Thorsten Jolitz
2014-09-28 22:09             ` 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=87ha03qv19.fsf@gmail.com \
    --to=aaronecay@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 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).