From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: org-context at the beginning of a link Date: Sat, 22 Nov 2014 07:23:32 -0800 Message-ID: References: <87egsw5gee.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsCXN-0003yR-Eq for emacs-orgmode@gnu.org; Sat, 22 Nov 2014 10:23:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XsCXH-0003kj-VO for emacs-orgmode@gnu.org; Sat, 22 Nov 2014 10:23:49 -0500 Received: from mx1.polytechnique.org ([129.104.30.34]:59648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsCXH-0003kZ-P1 for emacs-orgmode@gnu.org; Sat, 22 Nov 2014 10:23:43 -0500 Received: from top.local (unknown [73.15.189.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 76C881408EFA1 for ; Sat, 22 Nov 2014 16:23:39 +0100 (CET) In-Reply-To: <87egsw5gee.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Fri, 21 Nov 2014 23:37:45 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2014-11-21 23:37, Nicolas Goaziou writes: > Hello, > > Alan Schmitt 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 =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJUcKp5AAoJEAQNCjtO0uXHMbgH/3oK9e65k+SaoVjG6Hxw8mh7 Vvs0ZCzteRNZC22+9hZUkhjCrhnxU/tQJKAFtsT79LHx9mw53rbbJrGlmLUNehrn VTaxrh18O36VaYikQR+XTjGRTkOu+GOOZzAa9IwKctl5fMzjqmOrqEsq90csXxpx tMdqwQab74U3KlKHoLVLxZg12NpqocuI9wT+b/s1KLxu8bB5vlOYjvcV12SUu4CW romlp6Rg8gHzStHoJtHrh0PS9SKgzpBA+PNRv5W/vhyvwuf9XuulmqODlPHP7L0v ep0Wx36yP145O6DELBYciqP2QDr78dtWC20MHKJzANVYT/QdkAmxzIAQr1q2mFg= =md1Y -----END PGP SIGNATURE----- --=-=-=--