egh / zotxt-emacs

142 stars 11 forks source link

Function `org-zotxt-update-reference-link-at-point` eats up spaces after the link #54

Closed codetrick closed 3 years ago

codetrick commented 3 years ago

emacs version: 27.1 zotxt-emacs version: 20210115.456

First, thanks for this very helpful package!

I found that the function will eat up spaces if the target link has spaces after it. I think it's because (org-element-context) returns the end position that is just before the next element / word. Fortunately there's a property :post-blank that we can use.

Proposed solution: Replace

                    (delete-region (org-element-property :begin ct)
                                   (org-element-property :end ct))

with

                    (delete-region (org-element-property :begin ct)
                                   (- (org-element-property :end ct)
                                      (org-element-property :post-blank ct)))
egh commented 3 years ago

This looks good to me! Can you file a pull request? Thanks.