Function: hywiki-consult-backlink
hywiki-consult-backlink is an autoloaded, interactive and
byte-compiled function defined in hywiki.el.
Signature
(hywiki-consult-backlink REFERENCE)
Documentation
Select a HyWikiWord backlink to REFERENCE with hywiki-consult-grep.
REFERENCE should be a string of "WikiWord" and optional "#suffix" which
is ignored. Unless grep or rg have Perl-style pcre2 support, matches
will include filenames that include the WikiWord.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
;;;###autoload
(defun hywiki-consult-backlink (reference)
"Select a HyWikiWord backlink to REFERENCE with `hywiki-consult-grep'.
REFERENCE should be a string of \"WikiWord\" and optional \"#suffix\" which
is ignored. Unless `grep' or `rg' have Perl-style pcre2 support, matches
will include filenames that include the WikiWord."
(interactive (list (hywiki-word-read "Select a WikiWord backlink for: "
(hywiki-word-at-point))))
;; Ensure any #suffix is stripped
(let ((wikiword (and (stringp reference) (not (string-empty-p reference))
(hywiki-word-strip-suffix reference))))
(unless wikiword
(user-error "(hywiki-consult-backlink): Invalid HyWikiWord: '%s'; must be capitalized, all alpha" wikiword))
(require 'consult)
(let* ((ignored-exts "kotl|org|otl|html|md")
(ripgrep-pcre (hypb:ripgrep-has-pcre-p))
(grep-pcre (hypb:grep-has-pcre-p))
(consult-ripgrep-args consult-ripgrep-args)
(consult-grep-args consult-grep-args)
(regexp (format "\\b%s\\b\\(?!\\.\\(%s\\)\\)" wikiword ignored-exts)))
(cond (ripgrep-pcre
(setq consult-ripgrep-args
(if (listp consult-ripgrep-args)
(append consult-ripgrep-args (list "-P"))
(concat consult-ripgrep-args " -P"))))
(grep-pcre
(setq consult-grep-args
(if (listp consult-grep-args)
(append consult-grep-args (list "-P"))
(concat consult-grep-args " -P"))))
;; No pcre support, so use a simpler grep expression that doesn't
;; filter out WikiWords embedded within filenames
(t (setq regexp (format "\\b%s\\b" wikiword))))
(minibuffer-with-setup-hook
(lambda ()
;; Disable the Org cache which can cause an 'Invalid search bound' error
(setq-local org-element-use-cache nil)
(setq-local org-fold-core-style 'overlays))
(hywiki-consult-grep regexp nil nil
(format "HyWiki Backlinks [%s]: " wikiword))))))