[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: overlap between cite syntax and link activation
From: |
Ihor Radchenko |
Subject: |
Re: overlap between cite syntax and link activation |
Date: |
Sun, 24 Apr 2022 15:19:39 +0800 |
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>> It's the second of the two stoppers that John identified.
>>
>> He seems to have reported a related issue last August, but it slipped
>> through the cracks.
>>
>> https://lists.gnu.org/archive/html/emacs-orgmode/2021-08/msg00303.html
> A long-term solution would be to apply fontification on top of parsed
> data exclusively. IIRC, I think Ihor started to work on something like
> this, but I don't know about the current state of that project.
Yeah, but I afraid that I will have to implement object-level caching to
get sustainable performance. Currently, I got something semi-working in
https://github.com/yantar92/org/tree/feature/org-font-lock-element, but
it still chocks on large paragraphs with a lot of emphasis objects.
> One short-term solution would be to use the same function to fontify
> links and cites. I.e., "org.el" could define
> `org-activate-cites-and-links', which in turn, would dispatch work to
> either `org-activate-links' or `org-cite-activate'.
A quick temporary fix could be like the attached. Or checking
(org-element-context) instead of direct call to citation parser.
Best,
Ihor
>From 033677f02141f498ca3e1a84e85bb4c9a6d189c9 Mon Sep 17 00:00:00 2001
Message-Id:
<033677f02141f498ca3e1a84e85bb4c9a6d189c9.1650784539.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sun, 24 Apr 2022 15:14:26 +0800
Subject: [PATCH] org-cite-activate: Temporary fix to not fontify links as
citations
* lisp/oc.el (org-cite-activate): Use heuristics to check previous
char to determine if current match is not citation, but link.
---
lisp/oc.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/oc.el b/lisp/oc.el
index 360f1fadc..147bda368 100644
--- a/lisp/oc.el
+++ b/lisp/oc.el
@@ -1214,7 +1214,9 @@ (defun org-cite-activate (limit)
#'org-cite-fontify-default)))
(when (re-search-forward org-element-citation-prefix-re limit t)
(let ((cite (org-with-point-at (match-beginning 0)
- (org-element-citation-parser))))
+ (and (or (bolp)
+ (not (eq ?\[ (char-before))))
+ (org-element-citation-parser)))))
(when cite
(funcall activate cite)
;; Move after cite object and make sure to return
--
2.35.1