emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: org-mode-email <emacs-orgmode@gnu.org>,
	Bruce D'Arcus <bdarcus@gmail.com>,
	John Kitchin <jkitchin@andrew.cmu.edu>
Subject: Re: overlap between cite syntax and link activation
Date: Sun, 24 Apr 2022 15:19:39 +0800	[thread overview]
Message-ID: <874k2jne2c.fsf@localhost> (raw)
In-Reply-To: <87levxavtb.fsf@nicolasgoaziou.fr>

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

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-cite-activate-Temporary-fix-to-not-fontify-links.patch --]
[-- Type: text/x-patch, Size: 1201 bytes --]

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


  reply	other threads:[~2022-04-24  7:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-03 23:44 overlap between cite syntax and link activation John Kitchin
2022-04-04  0:55 ` Bruce D'Arcus
2022-04-22 12:47   ` Bruce D'Arcus
2022-04-22 17:10     ` Nicolas Goaziou
2022-04-24  7:19       ` Ihor Radchenko [this message]
2022-04-24  9:03         ` Nicolas Goaziou

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=874k2jne2c.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=bdarcus@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    --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).