Function: hywiki-completion-at-point
hywiki-completion-at-point is a byte-compiled function defined in
hywiki.el.
Signature
(hywiki-completion-at-point)
Documentation
Complete a HyWiki reference at point.
Each candidate is an alist with keys: file, line, text, and display.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
(defun hywiki-completion-at-point ()
"Complete a HyWiki reference at point.
Each candidate is an alist with keys: file, line, text, and display."
(setq hywiki--start-pos nil
hywiki--end-pos nil)
(let* ((ref-start-end (and (hywiki-active-in-current-buffer-p)
(not (hywiki-non-hook-context-p))
(hywiki-word-at t t)))
(ref (nth 0 ref-start-end))
(start (nth 1 ref-start-end))
(end (nth 2 ref-start-end))
(prefix (and start end (buffer-substring-no-properties start end)))
(existing-wikiword-prefix (when ref (hywiki-word-strip-suffix ref))))
(when prefix
(let* ((default-directory hywiki-directory)
(cmd (format "grep -nEH '^([ \t]*\\*+|#\\+TITLE:) +' ./%s*%s"
existing-wikiword-prefix
hywiki-file-suffix))
(output (shell-command-to-string cmd))
(lines (split-string output "[\n\r]" t))
(candidates
;; If no matching HyWiki pages were found, return nil
(unless (and (= 1 (length lines))
(string-match "No such file or directory" (car lines)))
(delq nil
(nconc
;; Return only candidates that start with 'existing-wikiword-prefix'
(seq-filter (lambda (str)
(string-prefix-p existing-wikiword-prefix str))
(hywiki-get-page-list))
(mapcar #'hywiki-format-grep-to-reference lines)))))
(candidates-alist (when candidates (mapcar #'list candidates))))
(when candidates-alist
(setq hywiki--char-before (char-before start)
hywiki--start-pos start
hywiki--end-pos end)
(list start end candidates-alist
:exclusive 'no
;; For company, allow any non-delim chars in prefix
;; :company-prefix-length t
;; :company-prefix-dirty t
;; Returning the prefix as (string . t) tells Company:
;; 'This is the prefix, and yes, it is currently valid (dirty).'
;; :company-prefix-snapshot (cons ref t)
;; This prevents the minibuffer/Corfu/Company from
;; re-parsing the # as a 'function quote' trigger.
:company-kind (lambda (_) 'keyword)
:annotation-function (lambda (_) " [HyWiki]")
;; Corfu uses this
:exit-function #'hywiki-completion-exit-function))))))