From 95a0dcb1370577409388e137dae98ec4c1af5bbd Mon Sep 17 00:00:00 2001 From: Max Nikulin 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