Function: markdown-ts--make-link-button
markdown-ts--make-link-button is a byte-compiled function defined in
markdown-ts-mode.el.gz.
Signature
(markdown-ts--make-link-button BEG END URL)
Documentation
Make the region from BEG to END a clickable button for URL.
For mailto: URIs, use url-mail-command. For other schemes
(e.g., http, ftp), open with browse-url. Otherwise, treat as
a relative file path and open with find-file.
Do not pass face to make-text-button: the link face is already
applied by markdown-ts--fontify-link-node via
treesit-fontify-with-override (with :override append), and
add-text-properties would otherwise replace the appended face
list with a single markdown-ts-link, clobbering an enclosing
heading face.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defvar url-mail-command) ; url/url-vars.el
(defun markdown-ts--make-link-button (beg end url)
"Make the region from BEG to END a clickable button for URL.
For mailto: URIs, use `url-mail-command'. For other schemes
\(e.g., http, ftp), open with `browse-url'. Otherwise, treat as
a relative file path and open with `find-file'.
Do not pass `face' to `make-text-button': the link face is already
applied by `markdown-ts--fontify-link-node' via
`treesit-fontify-with-override' (with `:override append'), and
`add-text-properties' would otherwise replace the appended face
list with a single `markdown-ts-link', clobbering an enclosing
heading face."
;; NOTE: URI scheme and host name are case-insensitive per RFC 3986
;; and RFC 7230.
(let ((case-fold-search nil))
(make-text-button beg end
'action (lambda (_button)
(cond
((string-prefix-p "#" url)
(markdown-ts--follow-fragment
(substring url 1)))
((string-match-p "\\`mailto:" url)
(funcall url-mail-command
(replace-regexp-in-string
"\\`mailto:" "" url)))
((string-match-p "\\`[a-z]+:" url)
(browse-url url))
(t (find-file url))))
'help-echo url)))