Function: tagref--parse-directive-at-point

tagref--parse-directive-at-point is a natively compiled function defined in tagref.el.

Signature

(tagref--parse-directive-at-point)

Documentation

Parse the tagref directive at point.

Returns (TYPE . NAME) where TYPE is "tag" or "ref" and NAME is the tag name, or nil if point is not inside a directive.

Source Code

;; Defined in /nix/store/mnch55hf9yszlb4dvfqhbqf0840v41qh-emacs-packages-deps/share/emacs/site-lisp/tagref.el
(defun tagref--parse-directive-at-point ()
  "Parse the tagref directive at point.
Returns (TYPE . NAME) where TYPE is \"tag\" or \"ref\" and NAME is
the tag name, or nil if point is not inside a directive."
  (save-excursion
    (let ((pt (point))
          (line-beg (line-beginning-position))
          (line-end (line-end-position)))
      (when (re-search-backward tagref--directive-start-regexp line-beg t)
        (let ((type (match-string 1))
              (name-start (match-end 0)))
          (when (re-search-forward "\\]" line-end t)
            (let* ((bracket-pos (1- (point)))  ; position of ]
                   (name-end-pos (1- bracket-pos)))  ; last char of name
              (when (and (>= pt name-start) (<= pt name-end-pos))
                (cons type (string-trim (buffer-substring-no-properties
                                         name-start bracket-pos)))))))))))