Closed wojnicki closed 6 months ago
Thanks for the report. Do you use svg-tag-mode from the example file ? And I'm not sure to get your point with the next-property-change
, can you elaborate?
The example file did not work for me for timestamps in the org mode - similar problem while editing. So I simplified the configuration:
(setq svg-tag-tags
`(
("\\[[0-9a-zA-Z :-]+\\]" . ((lambda (tag)
(svg-tag-make tag
:end -1
:beg 1
;; :crop-left t
:margin 0
))))))
It works fine with plain text. However not with org. I suspect that org-mode adds text properties to indicate timestamps. And it interferes with how svg-tag-mode locates the end of a tag. Hence my comment regarding svg-tag--cursor-function
. It finds a next property change (next-property-change
call) and assumes that it is because of a svg-tag, but it is due to the org-timestamp, and the ending of the tag is marked wrong (end
is wrong), which leads to improper editing I mentioned. Here is svg-tag--cursor-function
for reference:
(defun svg-tag--cursor-function (_win position direction)
"This function processes action at point. Action can be:
- Display the textual tag in the echo area
- Display the textual tag inline (this allow to edit it
- Do nothing"
(let ((beg (if (eq direction 'entered)
(previous-property-change (+ (point) 1))
(previous-property-change (+ position 1))))
(end (if (eq direction 'entered)
(next-property-change (point))
(next-property-change position))))
(if (eq svg-tag-action-at-point 'edit)
(if (eq direction 'left)
(font-lock-flush beg end )
(if (and (not view-read-only) (not buffer-read-only))
(font-lock-unfontify-region beg end ))))
(if (eq svg-tag-action-at-point 'echo)
(if (eq direction 'entered)
(let ((message-log-max nil))
(message (concat "TAG: "
(substring-no-properties
(string-trim
(buffer-substring beg end ))))))))))
Thanks for the report. Maybe using next-single-property-change
might solve the problem since we can specify which property to look for. I don't have the bandwidth to do it right now so if you want to give a try...
Thanks @rougier I think that's the right call. Here is a pull request.
Merged, thanks!
While using svg-tag-mode with org-mode, if there is:
(setq svg-tag-action-at-point 'edit)
and a tag is defined to cover org-mode date the editing experience is strange as it is shown below, just before entering the tag: after:If you set
svg-tag-action-at-point
to'echo
you could see that the tag length is not identified properly, it is:[2024-02-06 Tue
instead of[2024-02-06 Tue]
. It guess it might be because of the way howsvg-tag--cursor-function
identifies the end of the tag by usingnext-property-change
.