emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Feraidoon Mehri <feraidoonmehri@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] lisp/org/ol.el: org-link-make-description-function is always applied
Date: Tue, 16 May 2023 20:55:24 +0330	[thread overview]
Message-ID: <CABKKTcgpdEtycrH-SjuT9oFtdVJMKc9vp_fXsgCuntpTEOiArw@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2023-05-16 17:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 17:25 Feraidoon Mehri [this message]
2023-05-16 19:03 ` [PATCH] lisp/org/ol.el: org-link-make-description-function is always applied Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABKKTcgpdEtycrH-SjuT9oFtdVJMKc9vp_fXsgCuntpTEOiArw@mail.gmail.com \
    --to=feraidoonmehri@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).