[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Public API change: How to handle function signature change gracefully
From: |
Benjamin Andresen |
Subject: |
Public API change: How to handle function signature change gracefully |
Date: |
Sun, 19 Apr 2020 08:42:19 +0200 (CEST) |
Hello everyone,
I would like to change the public API of the :face part of
`org-link-set-parameters':
(org-link-set-parameters "file" :face 'org-link)
My ultimate goal is to have org-links be able to be have their face changed
based on the contents, not just the path of the link.
I found the relevant code in org.el in the function `org-activate-links':
'face (pcase (org-link-get-parameter type :face)
((and (pred functionp) face) (funcall face path))
((and (pred facep) face) face)
((and (pred consp) face) face) ;anonymous
(_ 'org-link))
and would like to change this to
'face (pcase (org-link-get-parameter type :face)
((and (pred functionp) face) (funcall face path contents)) ;; this is the
change
((and (pred facep) face) face)
((and (pred consp) face) face) ;anonymous
(_ 'org-link))
Now that will introduce a host of call issues because the callees don't expect
to the amount of arguments changed under their bottom.
I would like some guidance how I could get what I think is neat: The contents
of the bracket-style links as an additional parameter to set faces on and not
breaking existing hookups.
I'm thinking to change the above code to look at the callee's function
signature and checking how many arguments it accepts and then use the right
funcall for the situation.
To make this more palatable I would suggest it's changed so that the 2nd
argument will be a list of alists or keywords so to not have this function
signature problem if someone else comes up with a reason to introduce yet more
data.
Thanks in advance,
Benjamin Andresen
- Public API change: How to handle function signature change gracefully,
Benjamin Andresen <=