Function: hywiki-get-referent

hywiki-get-referent is a byte-compiled function defined in hywiki.el.

Signature

(hywiki-get-referent WIKIWORD &optional ABSOLUTE-PATH-FLAG)

Documentation

Return the referent of HyWiki WIKIWORD or nil if it does not exist.

Add any suffix from WIKIWORD to the referent value. With optional non-nil ABSOLUTE-PATH-FLAG, if the referent value is a pathname, expand it relative to hywiki-directory.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hywiki.el
(defun hywiki-get-referent (wikiword &optional absolute-path-flag)
  "Return the referent of HyWiki WIKIWORD or nil if it does not exist.
Add any suffix from WIKIWORD to the referent value.  With optional non-nil
ABSOLUTE-PATH-FLAG, if the referent value is a pathname, expand it relative
to `hywiki-directory'."
  (when (and (stringp wikiword) (not (string-empty-p wikiword))
	     (string-match hywiki-word-with-optional-suffix-exact-regexp wikiword))
    (let* ((suffix (cond ((match-beginning 2)
			   (prog1 (substring wikiword (match-beginning 2))
			     ;; Remove any #section suffix in `wikiword'.
			     (setq wikiword (match-string-no-properties 1 wikiword))))
			  ((match-beginning 3)
			   (prog1 (substring wikiword (match-beginning 3))
			     ;; Remove any :Lnum:Cnum suffix in `wikiword'.
			     (setq wikiword (match-string-no-properties
					     1 wikiword))))))
	   (referent (hash-get (hywiki-get-singular-wikiword wikiword)
			       (hywiki-get-referent-hasht))))
      ;; If a referent type that can include a # or :L line
      ;; number suffix, append it to the referent-value.  Also, if
      ;; `absolute-path-flag' is non-nil, assume the referent value is a
      ;; filename and expand it relative to `hywiki-directory'.
      (when referent
        (hywiki--add-suffix-to-referent suffix
                                        (cons (car referent)
                                              (if absolute-path-flag
                                                  (expand-file-name
                                                   (cdr referent)
                                                   hywiki-directory)
                                                (cdr referent))))))))