Nico,

> At some point, someone will want to write foo#call_bar() without
> #call_bar() being replaced, and we will go back to point 0. IMO,
> zero-width space is the way to go, if only because it can already be
> used to escape other special characters in Org.

oof, of course!  color me convinced!

one concern: if i essentially "revert" the changes in
7efa0f2879226695ad9b309c9263a4d1b5d79e89, call_ and src_ all work, but i
get the ZERO WIDTH SPACE (ZSWP, \u200b) propagated into the resulting
output file (.html, .tex). it doesn't seem to do any "harm", but, i find
it disquieting (being an ASCII-type by birth, if not by current usage).

the below patch, basically my #-paste patch turned into a \u200b-paste
patch, gets rid of the ZWSP in the output file in the case of
\u200bcall_, \u200bsrc_ (**), but, leaves it for all other uses, i.e.,
\u200b=fubar=.  this inconsistency i *also* find disquieting, sigh; i
can imagine the great-regexp in the sky in org-element.el could get rid
of all these prefixing ZWSPs, but i'd not proceed in this direction
without (policy, at least) direction.

cheers, Greg

(**) btw, if one wants \u200b<<RESULTS OF CALL_FOO()>> in the output,
one prefixes CALL_FOO() with *two* ZWSPs.

>From df94d943d085947212d96eddec9870d7dca0ea23 Mon Sep 17 00:00:00 2001
From: Greg Minshall <minsh...@acm.org>
Date: Thu, 1 Feb 2018 11:32:59 +0530
Subject: [PATCH] use ZERO WIDTH SPACE as a separator for call_, src_

(but, don't leave around in output)
---
 lisp/org-element.el         | 15 +++++++++------
 testing/lisp/test-ob-exp.el |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 5af2d6e..f550b89 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -161,8 +161,9 @@ specially in `org-element--object-lex'.")
 		      ;; entity, latex fragment.
 		      "\\\\\\(?:[a-zA-Z[(]\\|\\\\[ \t]*$\\|_ +\\)"
 		      ;; Objects starting with raw text: inline Babel
-		      ;; source block, inline Babel call.
-		      "\\(?:call\\|src\\)_"))
+		      ;; source block, inline Babel call.  possibly
+		      ;; prefixed with ZERO WIDTH SPACE
+		      "\u200b?\\(?:call\\|src\\)_"))
 		   "\\|")))
 
 (org-element--set-regexps)
@@ -2878,7 +2879,7 @@ Assume point is at the beginning of the babel call."
   (save-excursion
     (catch :no-object
       (when (let ((case-fold-search nil))
-	      (looking-at "call_\\([^ \t\n[(]+\\)[([]"))
+	      (looking-at "\u200b?\\<call_\\([^ \t\n[(]+\\)[([]"))
 	(goto-char (match-end 1))
 	(let* ((begin (match-beginning 0))
 	       (call (match-string-no-properties 1))
@@ -2932,7 +2933,7 @@ Assume point is at the beginning of the inline src block."
   (save-excursion
     (catch :no-object
       (when (let ((case-fold-search nil))
-	      (looking-at "src_\\([^ \t\n[{]+\\)[{[]"))
+	      (looking-at "\u200b?\\<src_\\([^ \t\n[{]+\\)[{[]"))
 	(goto-char (match-end 1))
 	(let ((begin (match-beginning 0))
 	      (language (match-string-no-properties 1))
@@ -4383,10 +4384,12 @@ to an appropriate container (e.g., a paragraph)."
 	  (let ((result (match-string 0)))
 	    (setq found
 		  (cond
-		   ((string-prefix-p "call_" result t)
+		   ((or (string-prefix-p "call_" result t)
+			(string-prefix-p "\u200bcall_" result t))
 		    (and (memq 'inline-babel-call restriction)
 			 (org-element-inline-babel-call-parser)))
-		   ((string-prefix-p "src_" result t)
+		   ((or (string-prefix-p "src_" result t)
+			(string-prefix-p "\u200bsrc_" result t))
 		    (and (memq 'inline-src-block restriction)
 			 (org-element-inline-src-block-parser)))
 		   (t
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index b0a3ab2..d8e1df1 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -231,7 +231,7 @@ Here is one at the end of a line. {{{results(=2=)}}}
   (should
    (equal "foosrc_emacs-lisp[]{(+ 1 1)}"
 	  (org-test-with-temp-text
-	      "foosrc_emacs-lisp[:exports code]{(+ 1 1)}"
+	      "foo\u200bsrc_emacs-lisp[:exports code]{(+ 1 1)}"
 	    (let ((org-babel-inline-result-wrap "=%s=")
 		  (org-export-use-babel t))
 	      (org-babel-exp-process-buffer))
-- 
2.7.4

Reply via email to