From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sHk9Lx+0xV70CQAA0tVLHw (envelope-from ) for ; Wed, 20 May 2020 22:50:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id uOYSKx+0xV4zEgAA1q6Kng (envelope-from ) for ; Wed, 20 May 2020 22:50:07 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 781F89404C6 for ; Wed, 20 May 2020 22:50:06 +0000 (UTC) Received: from localhost ([::1]:34610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbXXJ-0001Dm-FB for larch@yhetil.org; Wed, 20 May 2020 18:50:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbXWy-0001B5-SS for emacs-orgmode@gnu.org; Wed, 20 May 2020 18:49:44 -0400 Received: from [183.249.132.153] (port=1160 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbXWx-0005cV-8L for emacs-orgmode@gnu.org; Wed, 20 May 2020 18:49:44 -0400 Received: by dark.localdomain (Postfix, from userid 1000) id 1DBE5241A15; Thu, 21 May 2020 06:49:40 +0800 (HKT) References: <87pnazrlea.fsf@gmail.com> <87mu62hfq1.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.4; emacs 28.0.50 From: stardiviner To: Nicolas Goaziou Subject: Re: [Suggestion] add an API function for getting link description In-reply-to: <87mu62hfq1.fsf@nicolasgoaziou.fr> Date: Thu, 21 May 2020 06:49:39 +0800 Message-ID: <874ksa8bng.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 183.249.132.153 (deferred) Received-SPF: softfail client-ip=183.249.132.153; envelope-from=numbchild@gmail.com; helo=dark.localdomain X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/20 18:47:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=0.9, RDNS_NONE=0.793, SPF_SOFTFAIL=0.665, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: numbchild@gmail.com Cc: Org Mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.91 X-TUID: VxkkTD8FK0cF =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> I found org link can't get link description easily. >> >> I googled it how to get link description. Found this solution. But it's = not intuitive. >> >> #+begin_src emacs-lisp >> (defun get-description-at-point () >> (interactive) >> (let ((link (org-element-context))) >> (message "%s" (buffer-substring (org-element-property :contents-begi= n link) >> (org-element-property :contents-end = link))))) >> #+end_src >> >> Why now support this? >> >> #+begin_src emacs-lisp >> (org-element-property :desc (org-element-context)) >> #+end_src >> >> Maybe the key ~:desc~ could be more meaningful detailed. > > Links with description are not leaf elements in the AST. I.e., the > parser needs to go deeper. As any non-leaf object, as, e.g., bold, it > has :contents-begin and :contents-end properties. Adding :desc would > duplicate information for no good reason. Hmm, I get the reason. Thanks for explanation. > > I see no problem writing an helper function once, and use it often. > > Besides, there are other, slightly different implementations of this > function, e.g., > > (defun get-description-at-point-2 () > (and (org-at-regexp-p org-link-bracket-re) (match-string 2))) > > This one is fuzzier, it will get description in fake links too (e.g., in > comments, property drawers=E2=80=A6), but will be faster. So there is no = single > function that fits every need. > Good to know another faster implementation. Thankful. Regards, =2D --=20 [ stardiviner ] I try to make every word tell the meaning that I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 =20=20=20=20=20=20 =2D----BEGIN PGP SIGNATURE----- iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7FtAMUHG51bWJjaGls ZEBnbWFpbC5jb20ACgkQG13xyVromsNQBQf/RiEZsKS5NXhcta1RGftiUYGPah4l GQX0hrc+x/1Edm8ZGDLDXFy81LQVo1Min2dNxmEFnGqNjp8stfX6LYC5oxbt1Ye5 2FpejBGNyxvjZ/LpPwsIRr4xt3wlp2aNhoKO6VrqbLxJtxf92/Y9rccLBxNmzH7z xBXSDqrf5xBv+NC8hPTKbvPbo2b9OcJrFkF8cyBWU3T64iMqs6+F5TdmBZwOscXB NSu8Qha5+1QCz8pukk2iTvilzi37rdxRweOBDWvjKRmVdAQk35IoPop2Ip37OmRo tVqOx6Cc/7n0zTyhsYN36N5CsacPlR9FagzaroZ/9Jsp5DJCwtVh4YXU8A=3D=3D =3Dt/oC =2D----END PGP SIGNATURE-----