branch: externals/org-remark commit 6038ab7c308aaa537fd4f99f0e7b6e8320e44b8f Author: Noboru Ota <m...@nobiot.com> Commit: Noboru Ota <m...@nobiot.com>
fix: align highlight and position When text was inserted directly on the position of the mark (begin or end of a highlighted text region), the recorded location stored in the marginalia was not in sync with the highlight. This was because of the default marker insertion type (`marker-insertion-type`). It's by default `nil`. It needs to be `t` for all the begin and end position of each highlight. --- org-marginalia.el | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/org-marginalia.el b/org-marginalia.el index 6edbe8af58..c04ba29818 100644 --- a/org-marginalia.el +++ b/org-marginalia.el @@ -184,10 +184,14 @@ beginning point; this should be useful when `om/next' and (add-text-properties beg end '(font-lock-face om/highlighter)) ;; This beg and end are not always in sync when you change the text in it (add-text-properties beg end `(om/id ,id)) - ;; Keep track in a local variable - ;; It's alist; don't forget the dot (beg . end) - ;; The dot "." is imporant to make the car/cdr "getter" interface clean - (push `(,id ,(set-marker (make-marker) beg) . ,(set-marker (make-marker) end)) + ;; Keep track in a local variable It's alist; don't forget the dot + ;; (beg . end) + ;; The dot "." is imporant to make the car/cdr "getter" interface clean. + + ;; Also, `set-marker-insertion-type' to set the type t is necessary to move + ;; the cursor in sync with the font-lock-face property of the text property. + (push `(,id + ,(om/make-highlight-marker beg) . ,(om/make-highlight-marker end)) om/highlights) (om/sort-highlights-list)) @@ -395,6 +399,15 @@ creat a new headline at the end of the buffer." (when om/highlights (setq om/highlights (seq-sort-by (lambda (s) (car (cdr s))) #'< om/highlights)))) +(defun om/make-highlight-marker (point) + "Return marker of the insertion-type t. +The insertion-type is important in order for the highlight +position (beg and end points) in sycn with the highlited text +properties." + (let ((marker (set-marker (make-marker) point))) + (set-marker-insertion-type marker t) + marker)) + ;;;; Footer (provide 'org-marginalia)