Function: hfy-prepare-index-i

hfy-prepare-index-i is a byte-compiled function defined in htmlfontify.el.gz.

Signature

(hfy-prepare-index-i SRCDIR DSTDIR FILENAME &optional STUB MAP)

Documentation

Prepare a tags index buffer for SRCDIR.

hfy-tags-cache must already have an entry for SRCDIR for this to work. hfy-page-header, hfy-page-footer, hfy-link-extn and hfy-extn all play a part here.

If STUB is set, prepare an (appropriately named) index buffer specifically for entries beginning with STUB.

If MAP is set, use that instead of hfy-tags-cache. FILENAME is the name of the file being indexed. DSTDIR is the output directory, where files will be written.

Source Code

;; Defined in /usr/src/emacs/lisp/htmlfontify.el.gz
(defun hfy-prepare-index-i (srcdir dstdir filename &optional stub map)
  "Prepare a tags index buffer for SRCDIR.
`hfy-tags-cache' must already have an entry for SRCDIR for this to work.
`hfy-page-header', `hfy-page-footer', `hfy-link-extn' and `hfy-extn'
all play a part here.

If STUB is set, prepare an (appropriately named) index buffer
specifically for entries beginning with STUB.

If MAP is set, use that instead of `hfy-tags-cache'.
FILENAME is the name of the file being indexed.
DSTDIR is the output directory, where files will be written."
  ;;(message "hfy-write-index");;DBUG
  (let ((cache-entry  (assoc srcdir (or map hfy-tags-cache)))
        (cache-hash    nil)
        (tag-list      nil)
        (index-file
         (concat filename (if stub (concat "." stub) "") hfy-extn))
        (index-buf     nil))
    (if (not (and cache-entry
                  (setq cache-hash (cadr cache-entry))
                  (setq index-buf  (get-buffer-create index-file))))
        nil ;; noop
      (maphash (lambda (K _V) (push K tag-list)) cache-hash)
      (setq tag-list (sort tag-list 'string<))
      (set-buffer index-buf)
      (erase-buffer)
      (insert (funcall hfy-page-header filename "<!-- CSS -->"))
      (insert "<table class=\"index\">\n")

      (dolist (TAG tag-list)
        (let ((tag-started nil))
          (dolist (DEF (gethash TAG cache-hash))
            (if (and stub (not (string-match (concat "^" stub) TAG)))
                nil ;; we have a stub and it didn't match: NOOP
              (let ((file (car  DEF))
                    (line (cadr DEF)))
                (insert
                 (format
                  (concat
                   "  <tr>                                   \n"
                   "   <td>%s</td>                           \n"
                   "   <td><a href=\"%s%s\">%s</a></td>      \n"
                   "   <td><a href=\"%s%s#%s.%d\">%d</a></td>\n"
                   "  </tr>                                  \n")
                  (if (string= TAG tag-started) "&nbsp;"
                    (format "<a name=\"%s\">%s</a>" TAG TAG))
                  file (or hfy-link-extn hfy-extn) file
                  file (or hfy-link-extn hfy-extn) TAG line line))
                (setq tag-started TAG))))))
      (insert "</table>\n")
      (insert (funcall hfy-page-footer filename))
      (and dstdir (cd dstdir))
      (set-visited-file-name index-file)
      index-buf) ))