Rens Oliemans <[email protected]> writes:

> +                 (let* ((end (org-element-property :end link))
> +                        (original (buffer-substring begin end))
> +                        ;; the URL might be in [[https://...]]
> +                        ;; format or "just" in https://... format.
> +                        (url (if (string-match (rx string-start
> +                                                   (or (seq "[[" (group (seq 
> "https://"; (* anything))) "]]")
> +                                                       (seq "<" (group (seq 
> "https://"; (* anything))) ">"))
> +                                                   (? " ") ; 
> (buffer-substring begin end) might
> +                                                           ; have a trailing 
> space
> +                                                   string-end)
> +                                               original)
> +                                 (or
> +                                  (match-string 1 original)
> +                                  (match-string 2 original))
> +                               original))

Hmm, this is not exactly right. It seems that if a link is followed by a space
(or tab) character, (org-element-property :end link) will be after that
character. Consider this org file:

--- start ---
[[https://github.com/wallyqs/org-ruby]] .
[[https://github.com/wallyqs/org-ruby]].

#+begin_src elisp
  (org-element-map (org-element-parse-buffer) 'link
    (lambda (link)
      (let* ((beg (org-element-property :begin link))
           (end (org-element-property :end link))
           (length (- end beg)))
        (list beg end length))))
#+end_src

#+RESULTS:
|  1 | 41 | 40 |
| 43 | 82 | 39 |
--- end ---

is this intentional or am I misunderstanding the properties? While not a big
deal, it does makes the code a bit more complicated since I have to keep track
of whether the link contains a trailing space or not.

Reply via email to