Function: hywiki-make-referent-hasht

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

Signature

(hywiki-make-referent-hasht)

Documentation

Rebuild referent hasht from list of HyWiki page files and non-page entries.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20261030.2317/hywiki.el
(defun hywiki-make-referent-hasht ()
  "Rebuild referent hasht from list of HyWiki page files and non-page entries."
  (setq hywiki--any-wikiword-regexp-list nil
	hywiki--pages-directory hywiki-directory)
  ;; Try to load from a .hywiki.eld cache file if up-to-date
  (let* ((cache-file (hywiki-cache-default-file))
	 (cache-buffer (when (file-readable-p cache-file)
			 (find-file-noselect cache-file)))
         ;; Pre-9.3.1 versions of Hyperbole saved `hyperb:version' and
         ;; `hywiki-directory' in this cache, improperly overwriting the
         ;; current values.  To prevent this, we `let' bind these variables
         ;; during the cache read so that any changes are discarded.
	 (hywiki-loaded-flag (when cache-buffer
                               (let ((hyperb:version hyperb:version)
                                     (hywiki-directory hywiki-directory))
                                 (with-current-buffer cache-buffer
				   (widen)
				   (goto-char (point-min))
				   ;; Skip past initial comments
				   (when (re-search-forward "^(" nil t)
				     (goto-char (1- (point)))
				     (condition-case ()
                                         (progn (eval (read (buffer-string)))
                                                t)
				       (error nil))))))))
    (if (and hywiki-loaded-flag (not (hywiki-directory-modified-p)))
	;; Rebuild from loaded data
        (prog1 (setq hywiki--referent-hasht (hash-make hywiki--referent-alist t))
	  (setq hywiki--referent-alist nil))
      (when hywiki-loaded-flag
        ;; Rebuild from loaded data to get non-page-elts
        ;; !! TODO FIX - Delete out-of-date page file entries
        (setq hywiki--referent-hasht (hash-make hywiki--referent-alist t)
              hywiki--referent-alist nil))
      ;; Read `hywiki-directory' for current page files and merge with
      ;; non-page referents
      (let* ((page-files (hywiki-get-page-files))
	     (non-page-elts (when (hash-table-p hywiki--referent-hasht)
			      (delq nil
				    (hash-map 'hywiki-non-page-elt
					      hywiki--referent-hasht))))
	     (non-page-hasht (when non-page-elts (hash-make non-page-elts)))
	     (key)
	     (page-elts (delq nil (mapcar (lambda (file)
					    (setq key (file-name-sans-extension file))
					    (unless (and non-page-hasht
                                                         (hash-get key non-page-hasht))
					      (cons (cons 'page file) key)))
					  page-files)))
             (page-hasht (hash-make page-elts)))
	(setq hywiki--referent-hasht
              (cond
               ((and non-page-hasht page-hasht)
                (hash-merge non-page-hasht page-hasht))
               (non-page-hasht)
               (t page-hasht)))))))