emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to set org-make-link-description-function


From: John Kitchin
Subject: Re: [O] How to set org-make-link-description-function
Date: Fri, 13 Apr 2018 13:32:08 -0700

Here is a globally defined version that would let you define a function for any other kind of link I think. There are probably many variations on this theme, like storing functions in some variable as an alist, etc. Something like that is what would happen if this was defined in the link parameters.

#+BEGIN_SRC emacs-lisp
(defun my-comp (&optional arg)
  (format "fruit:%s"
          (completing-read "Choose a fruit: " '("apple" "orange" "grapes" "kiwi"))))

(org-link-set-parameters "fruit" 
                         :complete 'my-comp)


(defun org-fruit-make-link-description (link desc)
  (replace-regexp-in-string "fruit:" "" link))


(setq org-make-link-description-function
      (lambda (link desc)
(let* ((link-type (car (s-split ":" link)))
       (make-func (intern (format "org-%s-make-link-description" link-type))))
  (if (fboundp make-func)
      (funcall make-func link desc)
    desc))))
#+END_SRC

John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803

On Fri, Apr 13, 2018 at 10:23 AM, Eric Abrahamsen <address@hidden> wrote:
John Kitchin <address@hidden> writes:

> Not with the way I wrote it. It should only affect your links and pass everything else through I
> think.

I just meant, you can only have one of these functions set. So if I
provide special behavior for ebdb links, no other function would be able
to do the equivalent for some other type of link.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]