Function: html-current-buffer-ids

html-current-buffer-ids is a byte-compiled function defined in sgml-mode.el.gz.

Signature

(html-current-buffer-ids)

Documentation

Return a list of IDs used in the current buffer.

The result is cached in html--buffer-ids-cache.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/sgml-mode.el.gz
(defun html-current-buffer-ids ()
  "Return a list of IDs used in the current buffer.
The result is cached in `html--buffer-ids-cache'."
  (let ((tick (buffer-modified-tick)))
    (if (eq (car html--buffer-ids-cache) tick)
        (cdr html--buffer-ids-cache)
      (let* ((dom
              (libxml-parse-html-region (point-min) (point-max)))
             (ids
              (seq-mapcat
               (lambda (el)
                 (when-let* ((id-list
                              (cdr (assq 'id (dom-attributes el)))))
                   (split-string id-list)))
               (dom-by-id dom ""))))
        (setq-local html--buffer-ids-cache (cons tick ids))
        ids))))