Skip to content

Commit

Permalink
fix: Patch infinite loop by adding a secondary method #177
Browse files Browse the repository at this point in the history
Collective analysis efforts have found that infinite loop occurs when variables
`beg` and `end` have an identical value in `org-transclusion-remove`.

It's at the top of the function and looks like this:

(beg (marker-position (get-char-property (point)
                                         'org-transclusion-beg-mkr)))
(end (marker-position (get-char-property (point)
                                         'org-transclusion-end-mkr)))

These values are used to know the size of the transclusion to remove it. The
size of overlay on the source cannot be used because filter can alter the text
size. `text-property-search-forward` can be a reliable way to do this.

The message "(org-transclusion) Something is off" is still a WIP version. I
think we need to come up with a better message if the method above is deemed
viable as a preventive measure.
  • Loading branch information
nobiot committed May 12, 2024
1 parent b23ead2 commit 0506abc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion org-transclusion.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

;; Author: Noboru Ota <me@nobiot.com>
;; Created: 10 October 2020
;; Last modified: 20 April 2024
;; Last modified: 12 May 2024

;; URL: https://github.com/nobiot/org-transclusion
;; Keywords: org-mode, transclusion, writing
Expand Down Expand Up @@ -543,6 +543,13 @@ When success, return the beginning point of the keyword re-inserted."
(keyword (org-transclusion-keyword-plist-to-string keyword-plist))
(tc-pair-ov (get-char-property (point) 'org-transclusion-pair)))
(progn
(when (equal beg end)
(message "(org-transclusion) Something is off")
;; We need to know the size of the transclusion to remove it.
;; The size of overlay cannot be used because filter can change the text.
(when-let* ((prop-match (text-property-search-forward 'org-transclusion-beg-mkr)))
(setq beg (prop-match-beginning prop-match))
(setq end (prop-match-end prop-match))))
;; Need to retain the markers of the other adjacent transclusions
;; if any. If their positions differ after insert, move them back
;; beg or end
Expand Down

0 comments on commit 0506abc

Please sign in to comment.