From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: Re: [Feature proposal] Add :description function to org-link-parameters Date: Sat, 03 Aug 2019 10:35:59 +0800 Message-ID: <87y30bc6wg.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> References: <871ry3eety.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:44579) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htjv4-00047P-5D for emacs-orgmode@gnu.org; Fri, 02 Aug 2019 22:37:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htjv2-0003yd-4M for emacs-orgmode@gnu.org; Fri, 02 Aug 2019 22:37:18 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:34467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htjut-0003wU-TR for emacs-orgmode@gnu.org; Fri, 02 Aug 2019 22:37:10 -0400 Received: by mail-pf1-x42f.google.com with SMTP id b13so36897949pfo.1 for ; Fri, 02 Aug 2019 19:37:07 -0700 (PDT) In-Reply-To: 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" To: John Kitchin , emacs-orgmode@gnu.org Oops. Indeed, :desk should be replaced with :description. I used :desk property in my personal config, but it may be confusing for others. Best, Ihor John Kitchin writes: > This sounds reasonable. I was a little confused with the mixture of > of description and desk in the code below. If you replace desk with > description everywhere in your code is that what you mean? > > Ihor Radchenko writes: > >> Hi, >> >> Wondering if anyone is interested in adding a new org-link property to >> customise generating the link description. >> >> For now, there is global org-link-make-description-function, which is >> shared among all the link types. If would be more convenient if the >> description function can be set independently for different link types. >> >> I propose to use :description property in org-link-parameters. A sample >> implementation working with current org version is below: >> >> #+begin_src emacs-lisp >> (defun yant/org-make-link-description-function (link desk) >> "Return description of the link LINK according to :description link property. >> Return DESK if :desk is not set." >> (let ((fun (org-link-get-parameter (car (split-string link ":")) :description))) >> (if (functionp fun) >> (funcall fun link desk) >> desk))) >> >> (setq org-make-link-description-function #'yant/org-make-link-description-function) >> #+end_src >> >> Example usage: >> >> #+begin_src emacs-lisp >> (defun org-id-link-desk (link desk) >> "Description function for id: link." >> (let ((id (cadr (split-string link ":")))) >> (org-with-point-at (org-id-find id 'marker) >> (s-replace "||" "/" (yant/task-fulltitle))))) >> >> (org-link-set-parameters "id" >> :desk #'org-id-link-desk) >> #+end_src >> >> Best, >> Ihor > > > -- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg