On 2014-11-21 23:37, Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Hello,
>
> Alan Schmitt <alan.schm...@polytechnique.org> writes:
>
>> I'm using a function that relies on `org-element-link-parser'. According
>> to the documentation, the point needs to be at the element of the link
>> for it to work.
>
> Not what you are asking for, but it is probably wrong to call this
> function directly. If you want to parse something, it's better to use
> `org-element-context' (or `org-element-at-point' but it doesn't fit
> here).

Thank you for the suggestion. The reason I was using `org-context' is
because it is used in `org-next-link'.

Here is what I ended up doing. It works great, but please don't hesitate
to criticize is.

#+begin_src emacs-lisp
(defun as/org-link-p (elt)
  (eq 'link (org-element-type elt)))

(defun as/fetch-element-link (elt)
  (org-element-property :raw-link elt))

(defun as/fetch-current-or-next-link ()
  (let ((elt (org-element-context)))
    (save-excursion
      (as/fetch-element-link
       (if (as/org-link-p elt)
           elt
         (progn (org-next-link) (org-element-context)))))))
#+end_src

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

Attachment: signature.asc
Description: PGP signature

Reply via email to