Function: hsys-denote-link-at-p

hsys-denote-link-at-p is a byte-compiled function defined in hsys-denote.el.

Signature

(hsys-denote-link-at-p &optional ORG-LINK-START ORG-LINK-END)

Documentation

If in a denote link, return (link-string link-start link-end), else nil.

Start and end positions exclude any delimiters and any description part of a link. Optional ORG-LINK-START and ORG-LINK-END include any delimiters; this means point is within an Org link but still need to check if it is a denote link.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hsys-denote.el
(defun hsys-denote-link-at-p (&optional org-link-start org-link-end)
  "If in a denote link, return (link-string link-start link-end), else nil.
Start and end positions exclude any delimiters and any description part of a
link.  Optional ORG-LINK-START and ORG-LINK-END include any delimiters;
this means point is within an Org link but still need to check if it is a
denote link."
  (when (require 'denote nil t)
    (let (link-start-end
          start
          end)
      (cond
       ;; Previously detected Org link
       ((and (integerp org-link-start) (integerp org-link-end)
             (save-excursion
               (goto-char org-link-start)
               (looking-at "\\(\\[\\[\\)?\\(denote:[^][\n\r\f\"]+\\)")))
        (setq start (match-beginning 2)
              end (min (match-end 2) org-link-end))
        (list (buffer-substring-no-properties start end) start end))

       ;; String delimited
       ((setq link-start-end (hypb:in-string-p 1 :range))
        (when (string-match-p "\\`denote:" (car link-start-end))
          link-start-end))

       ;; Org link (may or may not have square bracket delimiters); if does
       ;; not, then can't allow spaces in the section name
       ((setq link-start-end (hsys-org-link-at-p)
              org-link-start (nth 0 link-start-end)
              org-link-end (nth 0 link-start-end))
        (when (save-excursion
                (goto-char org-link-start)
                (or
                 ;; Don't allow section spaces
                 (looking-at "\\(\\)\\(denote:[^][ \t\n\r\f\"]+\\)")
                 ;; Do allow section spaces
                 (looking-at "\\(\\[\\[\\)\\(denote:[^][\n\r\f\"]+\\)")))
          (list (match-string-no-properties 2) (match-beginning 2) (match-end 2))))

       ;; Non-delimited
       (t (let ((id-regexp (hys-denote-get-link-regexp))
                (eol (line-end-position))
                (opoint (point))
                found)
            (save-excursion
              (goto-char (line-beginning-position))
              (while (and (not found) (re-search-forward id-regexp eol t))
                (when (and (<= (match-beginning 0) opoint)
                           (> (point) opoint))
                  (setq found t)))
              found)
            (when found
              ;; Return (id-reference ref-start ref-end)
              (list (substring-no-properties (match-string-no-properties 0))
                    (match-beginning 0) (match-end 0)))))))))