From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [Feature proposal] Add :description function to org-link-parameters Date: Mon, 07 Oct 2019 10:52:55 +0800 Message-ID: <87lftxi7w8.fsf@gmail.com> References: <871ry3eety.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:45728) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHJ8w-0008SF-0V for emacs-orgmode@gnu.org; Sun, 06 Oct 2019 22:53:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHJ8v-00038k-1X for emacs-orgmode@gnu.org; Sun, 06 Oct 2019 22:53:01 -0400 Received: from [220.187.135.75] (port=58356 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iHJ8u-00037T-Ls for emacs-orgmode@gnu.org; Sun, 06 Oct 2019 22:53:00 -0400 In-reply-to: <871ry3eety.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> 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 I propose this feature too. Hope can add this. 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 -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3