emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vladimir Panteleev <git@thecybershadow.net>
To: emacs-orgmode@gnu.org
Cc: Vladimir Panteleev <git@thecybershadow.net>
Subject: [PATCH v2 1/3] ob-table: Fix org-sbe's handling of quotes in cell values
Date: Mon, 19 Mar 2018 00:23:12 +0000	[thread overview]
Message-ID: <20180319002314.8162-2-git@thecybershadow.net> (raw)
In-Reply-To: <20180319002314.8162-1-git@thecybershadow.net>

* ob-table.el (org-sbe): org-sbe did the wrong thing when given a
reference to a cell containing quotes or backslashes, because it would
simply wrap any $-prefixed value in quotes, without any escaping. Fix
this by using "%S" (instead of "\"%s\"").

* test-ob-table.el: Add test.
---
 lisp/ob-table.el              |  2 +-
 testing/lisp/test-ob-table.el | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-table.el b/lisp/ob-table.el
index f6a5c88e4..105aca5e2 100644
--- a/lisp/ob-table.el
+++ b/lisp/ob-table.el
@@ -112,7 +112,7 @@ as shown in the example below.
 				      (prog1 nil (setq quote t))
 				    (prog1
 					(cond
-					 (quote (format "\"%s\"" el))
+					 (quote (format "%S" el))
 					 ((stringp el) (org-no-properties el))
 					 (t el))
 				      (setq quote nil))))
diff --git a/testing/lisp/test-ob-table.el b/testing/lisp/test-ob-table.el
index da136cbee..3d9b1d160 100644
--- a/testing/lisp/test-ob-table.el
+++ b/testing/lisp/test-ob-table.el
@@ -30,6 +30,28 @@
 ;;   (org-test-at-id "6d2ff4ce-4489-4e2a-9c65-e3f71f77d975"
 ;;     (should (= 2 (sbe take-sqrt (n "4"))))))
 
+(ert-deftest test-ob-table/sbe-quote ()
+  "Test that `org-sbe' can correctly handle cell values containing quotes."
+  (org-test-table-target-expect
+   "
+#+name: identity
+#+begin_src emacs-lisp :eval yes
+  x
+#+end_src
+
+| a\"b\"c | replace |
+"
+   "
+#+name: identity
+#+begin_src emacs-lisp :eval yes
+  x
+#+end_src
+
+| a\"b\"c | a\"b\"c |
+"
+   1
+   "#+TBLFM: $2 = '(org-sbe identity (x $$1))"))
+
 (provide 'test-ob-table)
 
 ;;; test-ob-table.el ends here
-- 
2.16.2

  reply	other threads:[~2018-03-19  0:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 22:58 [PATCH 0/3] org-sbe fixes Vladimir Panteleev
2018-03-07 22:58 ` [PATCH 1/3] ob-table: Fix org-sbe's handling of quotes in arguments Vladimir Panteleev
2018-03-12 23:15   ` Nicolas Goaziou
2018-03-13 19:16     ` Vladimir Panteleev
2018-03-14 13:49       ` Nicolas Goaziou
2018-03-14 14:03         ` Vladimir Panteleev
2018-03-14 15:00           ` Nicolas Goaziou
2018-03-14 16:23             ` Vladimir Panteleev
2018-03-18 22:24               ` Nicolas Goaziou
2018-03-18 22:43                 ` Vladimir Panteleev
2018-03-18 23:30                   ` Nicolas Goaziou
2018-03-19  0:23                     ` [PATCH v2 0/3] org-sbe fixes Vladimir Panteleev
2018-03-19  0:23                       ` Vladimir Panteleev [this message]
2018-03-19  0:23                       ` [PATCH v2 2/3] ob-table: Fix org-sbe's handling of list arguments Vladimir Panteleev
2018-03-19  0:23                       ` [PATCH v2 3/3] ob-table: Mention passing ranges as lists in org-sbe's documentation Vladimir Panteleev
2018-03-19 23:07                       ` [PATCH v2 0/3] org-sbe fixes Nicolas Goaziou
2018-03-25 18:24                         ` Alan Schmitt
2018-03-25 20:26                           ` Nicolas Goaziou
2018-03-25 20:40                             ` Vladimir Panteleev
2018-03-25 21:06                               ` Nicolas Goaziou
2018-03-25 22:08                                 ` Vladimir Panteleev
2018-03-26 20:16                                   ` Nicolas Goaziou
2018-03-26 21:33                                     ` Vladimir Panteleev
2018-03-26 21:42                                       ` Nicolas Goaziou
2018-03-26 21:53                                         ` Vladimir Panteleev
2018-03-27  6:21                                           ` Nicolas Goaziou
2018-03-26  8:12                                 ` Alan Schmitt
2018-03-26 21:40                                   ` Nicolas Goaziou
2018-03-27  1:01                                     ` Bastien
2018-03-07 22:58 ` [PATCH 2/3] ob-table: Fix org-sbe's handling of list arguments Vladimir Panteleev
2018-03-07 22:58 ` [PATCH 3/3] ob-table: Mention passing ranges as lists in org-sbe's documentation Vladimir Panteleev

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=20180319002314.8162-2-git@thecybershadow.net \
    --to=git@thecybershadow.net \
    --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).