emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-cite-activate causes org-fontify-like-in-org-mode to fail for a citation [9.6.4]
@ 2023-04-16 15:28 Lin Jian
  2023-04-17 10:48 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Jian @ 2023-04-16 15:28 UTC (permalink / raw)
  To: emacs-orgmode


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

Steps to reproduce this bug:
0. emacs -q
1. (require 'org)
2. (setq org-cite-global-bibliography '("/path/to/references.bib"))
3. Here is the content of /path/to/references.bib:

@article{23-access-aalope,
  author       = {Valentine Aalo and
                  Kostas P. Peppas and
                  George P. Efthymoglou},
  title        = {Performance Analysis of Beacon-Assisted Wireless Powered Communications
                  With Spatially Random Sensors},
  journal      = {{IEEE} Access},
  volume       = {11},
  pages        = {12754--12763},
  year         = {2023},
  url          = {https://doi.org/10.1109/ACCESS.2023.3241755},
  doi          = {10.1109/ACCESS.2023.3241755},
  timestamp    = {Sat, 25 Feb 2023 21:34:36 +0100},
  biburl       = {https://dblp.org/rec/journals/access/AaloPE23.bib},
  bibsource    = {dblp computer science bibliography, https://dblp.org}
}

4. (org-fontify-like-in-org-mode "[cite:@23-access-aalope]")
5. check the *Message* buffer and you will see:

font-lock-default-fontify-region: End of buffer

6. I think the message in step 5 is a bug.  If this bug is fixed, we
should see this in the *Message* buffer instead:

#("[cite:@23-access-aalope]" 0 6 (font-lock-multiline t face org-cite) 6 23 (font-lock-multiline t face (org-cite-key org-cite) mouse-face highlight help-echo "Valentine Aalo, Kostas P. Peppas, George P. Efthymoglou. Performance Analysis of Beacon-Assisted Wireless Powered Communications With Spatially Random Sensors, {IEEE} Access, 2023." keymap (keymap (mouse-1 . org-open-at-point))) 23 24 (font-lock-multiline t face org-cite))

Bellow is my findings of this bug.

(org-fontify-like-in-org-mode)
-> (font-lock-ensure)
  -> ...
    -> (font-lock-fontify-keywords-region) ;; [1]
      -> (org-cite-activate) ;; [2]
        -> (org-cite-basic-activate)
          -> (org-cite-basic--print-entry)
            -> (org-cite-basic--shorten-names)
              -> (split-string) ;; match data is changed here
            -> ...
      -> (org-cite-activate) ;; [3]
    -> (font-lock-fontify-keywords-region) ;; [4] [5]

At the end of [2], (match-beginning 0) is 1.  At the end of [3],
(match-beginning 0) is changed to 35 by split-string.  So, [4] is nil.
As a result, [5] runs, which causes an end-of-buffer error.

I propose wrapping the whole let[6] in save-match-data to fix this bug.

[1]: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/font-lock.el?h=emacs-28.2#n1760
[2]: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/oc.el?h=release_9.6.4#n1231
[3]: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/oc.el?h=release_9.6.4#n1235
[4]: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/font-lock.el?h=emacs-28.2#n1763
[5]: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/font-lock.el?h=emacs-28.2#n1764
[6]: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/oc.el?h=release_9.6.4#n1232

Emacs  : GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
Package: Org mode version 9.6.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG] org-cite-activate causes org-fontify-like-in-org-mode to fail for a citation [9.6.4]
  2023-04-16 15:28 [BUG] org-cite-activate causes org-fontify-like-in-org-mode to fail for a citation [9.6.4] Lin Jian
@ 2023-04-17 10:48 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2023-04-17 10:48 UTC (permalink / raw)
  To: Lin Jian; +Cc: emacs-orgmode

Lin Jian <me@linj.tech> writes:

> font-lock-default-fontify-region: End of buffer
>
> 6. I think the message in step 5 is a bug.  If this bug is fixed, we
> should see this in the *Message* buffer instead:
> ...
> At the end of [2], (match-beginning 0) is 1.  At the end of [3],
> (match-beginning 0) is changed to 35 by split-string.  So, [4] is nil.
> As a result, [5] runs, which causes an end-of-buffer error.
>
> I propose wrapping the whole let[6] in save-match-data to fix this bug.

Thanks fore reporting and debugging!
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c827341df

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-17 10:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-16 15:28 [BUG] org-cite-activate causes org-fontify-like-in-org-mode to fail for a citation [9.6.4] Lin Jian
2023-04-17 10:48 ` Ihor Radchenko

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).