* [PATCH] lisp/org/ol.el: org-link-make-description-function is always applied
@ 2023-05-16 17:25 Feraidoon Mehri
2023-05-16 19:03 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Feraidoon Mehri @ 2023-05-16 17:25 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 677 bytes --]
I have signed the copyright assignment before.
The change is very small, so I think taking a look at the diff is more
informative than I trying to explain it; the old code did not use
`org-link-make-description-function` when some other alternatives were
available, but my changes make it always use
`org-link-make-description-function` if set.
This change is a breaking API change, but I think the previous behavior was
a bug. If you want to preserve the old behavior, perhaps we should add a
new variable `org-link-postprocess-description-function`?
Changelog:
* lisp/org/ol.el (org-insert-link): org-link-make-description-function is
always applied to the description.
[-- Attachment #1.2: Type: text/html, Size: 814 bytes --]
[-- Attachment #2: 0001-lisp-org-ol.el-org-link-make-description-function-is.patch --]
[-- Type: application/octet-stream, Size: 1624 bytes --]
From 50e339cdf8633c7be8e924fb1727812464a2b6a2 Mon Sep 17 00:00:00 2001
From: NightMachinery <feraidoonmehri@gmail.com>
Date: Tue, 16 May 2023 20:48:42 +0330
Subject: [PATCH] lisp/org/ol.el: org-link-make-description-function is always
applied
* lisp/org/ol.el (org-insert-link): org-link-make-description-function is always applied to the description.
---
lisp/org/ol.el | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lisp/org/ol.el b/lisp/org/ol.el
index 9ad191c8f78..5c98366ea84 100644
--- a/lisp/org/ol.el
+++ b/lisp/org/ol.el
@@ -1978,15 +1978,18 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
(message "Can't get link description from org link parameter `:insert-description': %S"
def)
(sit-for 2)
- nil))))
+ nil))))))
+ (initial-input
+ (cond
(org-link-make-description-function
(condition-case nil
- (funcall org-link-make-description-function link desc)
+ (funcall org-link-make-description-function link initial-input)
(error
(message "Can't get link description from %S"
org-link-make-description-function)
(sit-for 2)
- nil))))))
+ nil)))
+ (t initial-input))))
(setq desc (if (called-interactively-p 'any)
(read-string "Description: " initial-input)
initial-input)))
--
2.39.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lisp/org/ol.el: org-link-make-description-function is always applied
2023-05-16 17:25 [PATCH] lisp/org/ol.el: org-link-make-description-function is always applied Feraidoon Mehri
@ 2023-05-16 19:03 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2023-05-16 19:03 UTC (permalink / raw)
To: Feraidoon Mehri; +Cc: emacs-orgmode
Feraidoon Mehri <feraidoonmehri@gmail.com> writes:
> The change is very small, so I think taking a look at the diff is more
> informative than I trying to explain it; the old code did not use
> `org-link-make-description-function` when some other alternatives were
> available, but my changes make it always use
> `org-link-make-description-function` if set.
>
> This change is a breaking API change, but I think the previous behavior was
> a bug. If you want to preserve the old behavior, perhaps we should add a
> new variable `org-link-postprocess-description-function`?
The truth is that old behaviour is not fully documented.
So, this part of code is extremely fragile.
See https://list.orgmode.org/orgmode/87mtb6w2rq.fsf@localhost/
May you go through the `org-insert-link' code and summarize its current
behaviour? Then, we can discuss further if and how we want to change it.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-16 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-16 17:25 [PATCH] lisp/org/ol.el: org-link-make-description-function is always applied Feraidoon Mehri
2023-05-16 19:03 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).