emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Intra-word markup: \relax
Date: Fri, 28 Jan 2022 19:12:51 +0700	[thread overview]
Message-ID: <st0mk5$fnv$1@ciao.gmane.io> (raw)
In-Reply-To: <4897bc60-b74f-ccfd-e13e-9b89a1194fdf@mailbox.org>

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

On 02/12/2021 17:50, Denis Maier wrote:
> 
> Currently, org syntax doesn't officially seem to support intra-word 
> emphasis. Am I missing something?
> If the assessment is correct: Is there a reason for this? And, shouldn't 
> that be officially added?

I have an idea how to implement *intra*/word/ markup with minimal change 
of Org syntax. At first I had a hope that it is enough to introduce 
\relax entity that expands to empty string, but it does not work for 
second part of words: *intra*\relax{}/word/ is exported to
     <b>intra</b>/word/.
So it is necessary to support consuming spaces after such entity similar 
to TeX commands:
     *intra*\relax /word/
In Org "a\_      b" already behaves in the same way.

I do not like zero-width spaces since they are invisible, so they are 
not really "text" markup. Moreover, it is better to filter them out 
during export.

Another failed idea was to use export snippet or a macro for such purpose:
     #+macro sep $1
     *intra*{{{sep()}}}/word/, *intra*@@html:@@/word/

Important point that suggested solution works for all export backends. I 
do not consider explicit export snippets as a workaround since it 
requires code for all backends in org files.

[-- Attachment #2: 0001-Intra-word-markup-relax.patch --]
[-- Type: text/x-patch, Size: 2278 bytes --]

From 95a0dcb1370577409388e137dae98ec4c1af5bbd Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Fri, 28 Jan 2022 18:55:54 +0700
Subject: [PATCH] Intra-word markup: \relax

lisp/org-element.el (org-element-entity-parser): Parse \relax entity
with following spaces.

lisp/org-entities.el (org-entities): Add "\relax " entities with various
number of spaces expanding to nothing.

Allow "*intra*\relax /word/" markup change withing continuous word.  It
is not enough to just add "relax" entity since while it allows
"*intra*\relax{}word", characters after "{}" are not considered as
emphasis markers "intra\relax{}/word/".  The name is similar to the TeX
command. Consuming spaces following a command is usual behavior of TeX
commands as well.
---
 lisp/org-element.el  | 2 +-
 lisp/org-entities.el | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index b82475a14..83001fd74 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3159,7 +3159,7 @@ a plist with `:begin', `:end', `:latex', `:latex-math-p',
 
 Assume point is at the beginning of the entity."
   (catch 'no-object
-    (when (looking-at "\\\\\\(?:\\(?1:_ +\\)\\|\\(?1:there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\(?2:$\\|{}\\|[^[:alpha:]]\\)\\)")
+    (when (looking-at "\\\\\\(?:\\(?1:\\(?:_\\|relax\\) +\\)\\|\\(?1:there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\(?2:$\\|{}\\|[^[:alpha:]]\\)\\)")
       (save-excursion
 	(let* ((value (or (org-entity-get (match-string 1))
 			  (throw 'no-object nil)))
diff --git a/lisp/org-entities.el b/lisp/org-entities.el
index 2bd4f2fe3..f6177c471 100644
--- a/lisp/org-entities.el
+++ b/lisp/org-entities.el
@@ -526,7 +526,12 @@ packages to be loaded, add these packages to `org-latex-packages-alist'."
 		     spaces
 		     spaces
 		     (make-string n ?\x2002))
-	       space-entities)))))
+	       space-entities))))
+   ;; Add "\relax " space-eating entity family for "intra\relax *word*" markup.
+   (mapcar (lambda (n)
+             (list (concat "relax" (make-string n ? )) "" nil "" "" "" ""))
+             (number-sequence 0 20)))
+
   "Default entities used in Org mode to produce special characters.
 For details see `org-entities-user'.")
 
-- 
2.25.1


  parent reply	other threads:[~2022-01-28 12:34 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 10:50 Org-syntax: Intra-word markup Denis Maier
2021-12-02 11:18 ` Ihor Radchenko
2021-12-02 11:30   ` Juan Manuel Macías
2021-12-02 11:36     ` Denis Maier
2021-12-02 12:01       ` Ihor Radchenko
2021-12-02 11:42     ` Marco Wahl
2021-12-02 11:50       ` Denis Maier
2021-12-02 12:10         ` Ihor Radchenko
2021-12-02 12:40           ` Denis Maier
2021-12-02 12:54             ` Ihor Radchenko
2021-12-02 13:14               ` Juan Manuel Macías
2021-12-02 13:28                 ` Denis Maier
2021-12-02 12:48           ` Max Nikulin
2021-12-02 12:02       ` Ihor Radchenko
2021-12-02 12:00     ` Ihor Radchenko
     [not found]       ` <87r1avtdjy.fsf@ucl.ac.uk>
2021-12-02 12:27         ` Denis Maier
2021-12-02 13:06           ` Eric S Fraga
2021-12-02 12:28       ` Denis Maier
2021-12-02 12:55         ` Ihor Radchenko
2021-12-02 11:58 ` Timothy
2021-12-02 12:26   ` Denis Maier
2021-12-02 13:07     ` Ihor Radchenko
2021-12-02 15:51       ` Max Nikulin
2021-12-02 18:11         ` Tom Gillespie
2021-12-02 19:09           ` Juan Manuel Macías
2021-12-04 13:07             ` Org-syntax: emphasis and not English punctuation Max Nikulin
2021-12-04 16:42               ` Juan Manuel Macías
2021-12-02 20:47           ` Org-syntax: Intra-word markup Denis Maier
2021-12-02 22:44             ` Samuel Wales
2021-12-03 14:53           ` Max Nikulin
2021-12-03 23:51           ` Tim Cross
2021-12-04 15:01             ` Max Nikulin
2021-12-05 23:34               ` Russell Adams
2021-12-05 23:37             ` Russell Adams
2021-12-06  1:39               ` Samuel Wales
2021-12-02 19:03       ` Nicolas Goaziou
2021-12-02 19:34         ` Juan Manuel Macías
2021-12-02 23:05           ` Nicolas Goaziou
2021-12-02 23:24             ` Juan Manuel Macías
2021-12-03 14:24         ` Max Nikulin
2021-12-03 15:01           ` Juan Manuel Macías
2021-12-04 15:57           ` Denis Maier
2021-12-04 17:53             ` Tom Gillespie
2021-12-04 18:37               ` John Kitchin
2021-12-04 21:16                 ` Juan Manuel Macías
2021-12-06 10:57                 ` Raw Org AST snippets for "impossible" markup Max Nikulin
2021-12-06 15:45                   ` Juan Manuel Macías
2021-12-06 16:56                     ` Juan Manuel Macías
2021-12-08 13:09                     ` Max Nikulin
2021-12-08 23:19                       ` Juan Manuel Macías
2021-12-08 23:35                         ` John Kitchin
2021-12-09  7:01                           ` Juan Manuel Macías
2021-12-09 14:56                             ` Max Nikulin
2021-12-09 16:11                               ` Juan Manuel Macías
2021-12-09 22:27                                 ` Juan Manuel Macías
2022-01-03 14:34                                   ` Max Nikulin
2021-12-04 19:04               ` Org-syntax: Intra-word markup Timothy
2021-12-04 21:48                 ` Tom Gillespie
2021-12-06 10:59                   ` Max Nikulin
2022-01-28 14:52                   ` Max Nikulin
2022-01-29  3:13                     ` Ihor Radchenko
2022-01-29 13:05                       ` Juan Manuel Macías
2022-02-02 15:28                         ` Max Nikulin
2022-02-02 20:01                           ` Juan Manuel Macías
2022-02-03 12:10                             ` Max Nikulin
2021-12-06 11:01               ` Denis Maier
2022-01-28 12:12 ` Max Nikulin [this message]
2022-01-28 13:13   ` [PATCH] Intra-word markup: \relax Juan Manuel Macías
2022-02-02 15:42     ` Max Nikulin

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='st0mk5$fnv$1@ciao.gmane.io' \
    --to=manikulin@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).