Function: embark-org-target-link
embark-org-target-link is a byte-compiled function defined in
embark-org.el.
Signature
(embark-org-target-link)
Documentation
Target Org link at point.
This targets Org links in any buffer, not just buffers in
org-mode or org-agenda-mode. Org links in any buffer can be
opened with org-open-at-point-global, which is the default
Embark action for Org links.
Source Code
;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark-org.el
;;; Links
;; The link support has a slightly complicated design in order to
;; achieve the following goals:
;; 1. RET should simply be org-open-at-point
;; 2. When the link is to a file, URL, email address or elisp
;; expression or command, we want to offer the user actions for
;; that underlying type.
;; 3. Even in those cases, we still want some actions to apply to the
;; entire link including description: actions to copy the link as
;; markdown, or just the link description or target.
;; So the strategy is as follows (illustrated with file links):
;; - The target will be just the file, without the description and
;; also without the "file:" prefix nor the "::line-number or search"
;; suffix. That way, file actions will correctly apply to it.
;; - The type will not be 'file, but 'org-file-link; that way we can
;; register a keymap for 'org-file-link that inherits from both
;; embark-org-link-map (with RET bound to org-open-at-point and a
;; few other generic link actions) and embark-file-map.
;; - The commands to copy the link at point in some format will be
;; written as commands that act on the Org link at point. This way
;; they are independently (plausibly) useful, and we circumvent the
;; problem that the whole Org link is not actually the target (just
;; the inner file is!).
;; Alternative design I considered: separate each target into two, a
;; whole link target which includes the description and brackets and
;; what not; and an "inner target" which is just the file or URL or
;; whatever. Cons of this approach: much target cycling is required!
;; First of all, an unadorned embark-dwim definitely should be
;; org-open-at-point, which means the whole link target would need
;; priority. That means that any file, URL, etc. actions would require
;; you to cycle first. This sounds very inconvenient, the above
;; slightly more complex design allows both whole-link and inner
;; target actions to work without cycling.
(defun embark-org-target-link ()
"Target Org link at point.
This targets Org links in any buffer, not just buffers in
`org-mode' or `org-agenda-mode'. Org links in any buffer can be
opened with `org-open-at-point-global', which is the default
Embark action for Org links."
(pcase (org-in-regexp org-link-any-re)
(`(,start . ,end)
;; We won't recognize unadorned http(s) or mailto links, as those
;; already have target finders (but if these links have either a
;; description, double brackets or angle brackets, then we do
;; recognize them as org links)
(unless (save-excursion (goto-char start) (looking-at "http\\|mailto"))
`(org-link ,(buffer-substring start end) ,start . ,end)))))