Function: markdown-insert-link

markdown-insert-link is an interactive and byte-compiled function defined in markdown-mode.el.

Signature

(markdown-insert-link)

Documentation

Insert new or update an existing link, with interactive prompt.

If the point is at an existing link or URL, update the link text, URL, reference label, and/or title. Otherwise, insert a new link. The type of link inserted (inline, reference, or plain URL) depends on which values are provided:

* If a URL and TEXT are given, insert an inline link: [TEXT](URL).
* If [REF] and TEXT are given, insert a reference link: [TEXT][REF].
* If only TEXT is given, insert an implicit reference link: [TEXT][].
* If only a URL is given, insert a plain link: <URL>.

In other words, to create an implicit reference link, leave the URL prompt empty and to create a plain URL link, leave the link text empty.

If there is an active region, use the text as the default URL, if it seems to be a URL, or link text value otherwise.

If a given reference is not defined, this function will additionally prompt for the URL and optional title. In this case, the reference definition is placed at the location determined by markdown-reference-location. In addition, it is possible to have the markdown-link-make-text-function function, if non-nil, define the default link text before prompting the user for it.

If markdown-disable-tooltip-prompt is non-nil, the user will not be prompted to add or modify a tooltip text.

Through updating the link, this function can be used to convert a link of one type (inline, reference, or plain) to another type by selectively adding or removing information via the prompts.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-insert-link ()
  "Insert new or update an existing link, with interactive prompt.
If the point is at an existing link or URL, update the link text,
URL, reference label, and/or title.  Otherwise, insert a new link.
The type of link inserted (inline, reference, or plain URL)
depends on which values are provided:

*   If a URL and TEXT are given, insert an inline link: [TEXT](URL).
*   If [REF] and TEXT are given, insert a reference link: [TEXT][REF].
*   If only TEXT is given, insert an implicit reference link: [TEXT][].
*   If only a URL is given, insert a plain link: <URL>.

In other words, to create an implicit reference link, leave the
URL prompt empty and to create a plain URL link, leave the link
text empty.

If there is an active region, use the text as the default URL, if
it seems to be a URL, or link text value otherwise.

If a given reference is not defined, this function will
additionally prompt for the URL and optional title.  In this case,
the reference definition is placed at the location determined by
`markdown-reference-location'.  In addition, it is possible to
have the `markdown-link-make-text-function' function, if non-nil,
define the default link text before prompting the user for it.

If `markdown-disable-tooltip-prompt' is non-nil, the user will
not be prompted to add or modify a tooltip text.

Through updating the link, this function can be used to convert a
link of one type (inline, reference, or plain) to another type by
selectively adding or removing information via the prompts."
  (interactive)
  (markdown--insert-link-or-image nil))