From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: [Feature proposal] Add :description function to org-link-parameters Date: Sat, 03 Aug 2019 00:01:45 +0800 Message-ID: <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]:59943) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta1A-0004SH-Pc for emacs-orgmode@gnu.org; Fri, 02 Aug 2019 12:02:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hta18-00084b-Ql for emacs-orgmode@gnu.org; Fri, 02 Aug 2019 12:02:56 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:39770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hta17-00083m-1W for emacs-orgmode@gnu.org; Fri, 02 Aug 2019 12:02:54 -0400 Received: by mail-pf1-x435.google.com with SMTP id f17so32268822pfn.6 for ; Fri, 02 Aug 2019 09:02:51 -0700 (PDT) Received: from localhost ([140.110.200.36]) by smtp.gmail.com with ESMTPSA id p67sm91694599pfg.124.2019.08.02.09.02.49 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 09:02:49 -0700 (PDT) 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: emacs-orgmode@gnu.org 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 -- 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