[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org-context at the beginning of a link
From: |
Alan Schmitt |
Subject: |
Re: [O] org-context at the beginning of a link |
Date: |
Sat, 22 Nov 2014 07:23:32 -0800 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (darwin) |
On 2014-11-21 23:37, Nicolas Goaziou <address@hidden> writes:
> Hello,
>
> Alan Schmitt <address@hidden> 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
signature.asc
Description: PGP signature