Function: markdown-insert-reference-definition
markdown-insert-reference-definition is a byte-compiled function
defined in markdown-mode.el.
Signature
(markdown-insert-reference-definition LABEL &optional URL TITLE)
Documentation
Add definition for reference LABEL with URL and TITLE.
LABEL is a Markdown reference label without square brackets. URL and TITLE are optional. When given, the TITLE will be used to populate the title attribute when converted to XHTML.
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-insert-reference-definition (label &optional url title)
"Add definition for reference LABEL with URL and TITLE.
LABEL is a Markdown reference label without square brackets.
URL and TITLE are optional. When given, the TITLE will
be used to populate the title attribute when converted to XHTML."
;; END specifies where to leave the point upon return
(let ((end (point)))
(cl-case markdown-reference-location
(end (goto-char (point-max)))
(immediately (markdown-end-of-text-block))
(subtree (markdown-end-of-subtree))
(header (markdown-end-of-defun)))
;; Skip backwards over local variables. This logic is similar to the one
;; used in ‘hack-local-variables’.
(when (and enable-local-variables (eobp))
(search-backward "\n\f" (max (- (point) 3000) (point-min)) :move)
(when (let ((case-fold-search t))
(search-forward "Local Variables:" nil :move))
(beginning-of-line 0)
(when (eq (char-before) ?\n) (backward-char))))
(unless (or (markdown-cur-line-blank-p)
(thing-at-point-looking-at markdown-regex-reference-definition))
(insert "\n"))
(insert "\n[" label "]: ")
(if url
(insert url)
;; When no URL is given, leave point at END following the colon
(setq end (point)))
(when (> (length title) 0)
(insert " \"" title "\""))
(unless (looking-at-p "\n")
(insert "\n"))
(goto-char end)
(when url
(message
(markdown--substitute-command-keys
"Reference [%s] was defined, press \\[markdown-do] to jump there")
label))))