[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasi
From: |
Ihor Radchenko |
Subject: |
Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’ |
Date: |
Thu, 18 Nov 2021 20:25:33 +0800 |
Max Nikulin <manikulin@gmail.com> writes:
> These regexps will always fail under some conditions, since it is not
> strict markup. An example is emphasis terminated inside link target
>
> /A link [[https://orgmode.org/?oops=true][Org Mode]]
Your example actually reveals a much bigger issue with current element
parser. Even though the link is fontified by Org, if you run
org-element-context on the link, it will return nil. The parsed sentence
will look like:
<begin italic>/A link [[https://orgmode.org/<end italic><begin ordinary
text - it is not a link!>?oops=true][Org Mode]]<end of ordinary text>
The reason behind is partially regexps used to detect emphasised text
and partially the way our parser works - no intersected objects are
allowed.
My intuition says that the current parser behaviour is not correct. It
would make more sense to prioritise link over italics. However, it would
require a major change in the parser - instead of a single pass, the
parser may parse different types of objects sequentially. The emphasis
objects should come last avoiding the markers to have different parents.
Nicolas, WDYT?
>> Maybe something like the attached?
>
> Thank you, Ihor. Another reason why I have not tried to do it myself is
> that it is necessary to test behavior for users who customized markers.
> The change should not be fatal for them. I have not checked it with you
> patch yet.
>
> I was considering some way to warn users if improper customization is
> detected (unexpected marker is noticed). It should be noticeable to make
> user aware of export issues but not too annoying.
>
>> +The characters in the alist must not be changed. They do not affect
>> +the actual Org syntax, just fontification.
>
> Since this is known point of abuses, maybe stronger words are appropriate.
>
> Do not change makers and do not add new ones to use custom markers for
> existing styles or to introduce new styles. Org syntax is not meant to
> be configurable and such modifications will not work with export. If you
> are interested in fontification of custom markup inside Emacs only,
> there are other ways to achieve desired effect.
> ...
> In addition, I do not like the following phrase in the manual:
>
>> To narrow down the list of available markup syntax, you can customize
>> org-emphasis-alist.
I updated the patch dropping your last suggested sentence in the
docstring. I find it not very helpful for the user. We should either say
nothing (as in the patch) or give a concrete reference how to "achieve
the desired effect".
Best,
Ihor
>From c950768bc08b4cae07ba3cb451d8af0abfec7dc8 Mon Sep 17 00:00:00 2001
Message-Id:
<c950768bc08b4cae07ba3cb451d8af0abfec7dc8.1637237807.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Tue, 16 Nov 2021 15:40:35 +0800
Subject: [PATCH] org-emphasis-alist: Update defcustom making emphasis
characters constant
* lisp/org.el (org-emphasis-alist): Mention that emphasis characters
should not be changed by user. Update the defcustom type accordingly.
* doc/org-manual.org (Emphasis and Monospace): Update the referece to
`org-emphasis-alist'.
---
doc/org-manual.org | 5 +++--
lisp/org.el | 41 ++++++++++++++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index c4bb7ef30..9fea2c42e 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -10814,9 +10814,10 @@ ** Emphasis and Monospace
exported verbatim.
#+vindex: org-fontify-emphasized-text
+#+vindex: org-emphasis-alist
To turn off fontification for marked up text, you can set
-~org-fontify-emphasized-text~ to ~nil~. To narrow down the list of
-available markup syntax, you can customize ~org-emphasis-alist~.
+~org-fontify-emphasized-text~ to ~nil~. For more fine-tuned
+fontification, you can customize ~org-emphasis-alist~.
** Subscripts and Superscripts
:PROPERTIES:
diff --git a/lisp/org.el b/lisp/org.el
index 603b57279..00ac00ab3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3833,18 +3833,49 @@ (defcustom org-emphasis-alist
marker characters and the face to be used by font-lock for highlighting
in Org buffers.
+Do not change the characters and do not add new ones to use custom
+markers for existing styles or to introduce new styles. Org syntax is
+not meant to be configurable and such modifications will not work with
+export.
+
You need to reload Org or to restart Emacs after customizing this."
:group 'org-appearance
:set 'org-set-emph-re
:version "24.4"
:package-version '(Org . "8.0")
- :type '(repeat
+ :type '(list
(list
- (string :tag "Marker character")
+ (const "*")
+ (choice
+ (face :tag "Bold emphasis face")
+ (plist :tag "Bold emphasis face property list")))
+ (list
+ (const "/")
+ (choice
+ (face :tag "Italic emphasis face")
+ (plist :tag "Italic emphasis face property list")))
+ (list
+ (const "_")
+ (choice
+ (face :tag "Underline emphasis face")
+ (plist :tag "Underline emphasis face property list")))
+ (list
+ (const "=")
+ (choice
+ (face :tag "Verbatim emphasis face")
+ (plist :tag "Verbatim emphasis face property list"))
+ (const verbatim))
+ (list
+ (const "~")
+ (choice
+ (face :tag "Code emphasis face")
+ (plist :tag "Code emphasis face property list"))
+ (const verbatim))
+ (list
+ (const "+")
(choice
- (face :tag "Font-lock-face")
- (plist :tag "Face property list"))
- (option (const verbatim)))))
+ (face :tag "Strike-through emphasis face")
+ (plist :tag "Strike-through emphasis face property list")))))
(defvar org-protecting-blocks '("src" "example" "export")
"Blocks that contain text that is quoted, i.e. not processed as Org syntax.
--
2.32.0
- c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/14
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Nicolas Goaziou, 2021/11/15
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/15
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Max Nikulin, 2021/11/17
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Samuel Wales, 2021/11/17
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’,
Ihor Radchenko <=
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Nicolas Goaziou, 2021/11/18
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/18
- Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Nicolas Goaziou, 2021/11/19
- [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/19
- Re: [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Nicolas Goaziou, 2021/11/19
- Re: [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/19
- Re: [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Nicolas Goaziou, 2021/11/20
- Re: [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/21
- Re: [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Nicolas Goaziou, 2021/11/22
- Re: [PATCH] Re: c47b535bb origin/main org-element: Remove dependency on ‘org-emphasis-regexp-components’, Ihor Radchenko, 2021/11/23