emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Greg Minshall <minshall@acm.org>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org Mode List <emacs-orgmode@gnu.org>,
	Kaushal Modi <kaushal.modi@gmail.com>
Subject: Re: non-space, paste, (???) character for inline results
Date: Thu, 01 Feb 2018 11:53:58 +0530	[thread overview]
Message-ID: <29086.1517466238@minshall-apollo.minshall.org> (raw)
In-Reply-To: Your message of "Wed\, 31 Jan 2018 19\:09\:58 +0100." <87607hzyq1.fsf@nicolasgoaziou.fr>

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

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-use-ZERO-WIDTH-SPACE-as-a-separator-for-call_-src_.patch --]
[-- Type: text/x-diff, Size: 2947 bytes --]

From df94d943d085947212d96eddec9870d7dca0ea23 Mon Sep 17 00:00:00 2001
From: Greg Minshall <minshall@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	other threads:[~2018-02-01  6:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30  8:29 non-space, paste, (???) character for inline results Greg Minshall
2018-01-30  9:15 ` Nicolas Goaziou
2018-01-30 13:06   ` Greg Minshall
2018-01-30 20:55     ` Nicolas Goaziou
2018-01-31  1:19       ` Greg Minshall
2018-01-31 11:13         ` Nicolas Goaziou
2018-01-31 15:12           ` Greg Minshall
2018-01-31 16:19             ` Nicolas Goaziou
2018-01-31 17:41               ` Greg Minshall
2018-01-31 17:52                 ` Kaushal Modi
2018-01-31 17:54                   ` Kaushal Modi
2018-01-31 18:09                 ` Nicolas Goaziou
2018-02-01  6:23                   ` Greg Minshall [this message]
2018-02-03 14:01                     ` Nicolas Goaziou
2018-02-03 14:27                       ` Greg Minshall
2018-02-03 14:31                         ` Nicolas Goaziou
2018-02-03 14:41                           ` Greg Minshall
2018-02-03 23:33                             ` Nicolas Goaziou
2018-02-05 23:15                               ` Greg Minshall

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=29086.1517466238@minshall-apollo.minshall.org \
    --to=minshall@acm.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.com \
    --cc=mail@nicolasgoaziou.fr \
    /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).