Function: bibtex-string-files-init

bibtex-string-files-init is a byte-compiled function defined in bibtex.el.gz.

Signature

(bibtex-string-files-init)

Documentation

Return initialization for bibtex-strings(var)/bibtex-strings(fun).

Use bibtex-predefined-strings and BibTeX files bibtex-string-files.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
(defun bibtex-string-files-init ()
  "Return initialization for `bibtex-strings'.
Use `bibtex-predefined-strings' and BibTeX files `bibtex-string-files'."
  (save-match-data
    (let ((dirlist (split-string (or bibtex-string-file-path default-directory)
                                 ":+"))
          (case-fold-search)
          string-files fullfilename compl bounds found)
      ;; collect absolute file names of valid string files
      (dolist (filename bibtex-string-files)
        (unless (string-match "\\.bib\\'" filename)
          (setq filename (concat filename ".bib")))
        ;; test filenames
        (if (file-name-absolute-p filename)
            (if (file-readable-p filename)
                (push filename string-files)
              (user-error "BibTeX strings file %s not found" filename))
          (dolist (dir dirlist)
            (when (file-readable-p
                   (setq fullfilename (expand-file-name filename dir)))
              (push fullfilename string-files)
              (setq found t)))
          (unless found
            (user-error "File %s not in paths defined via bibtex-string-file-path"
                        filename))))
      ;; parse string files
      (dolist (filename string-files)
        (with-temp-buffer
          (insert-file-contents filename)
          (goto-char (point-min))
          (while (setq bounds (bibtex-search-forward-string))
            (push (cons (bibtex-reference-key-in-string bounds)
                        (bibtex-text-in-string bounds t))
                  compl)
            (goto-char (bibtex-end-of-string bounds)))))
      (append bibtex-predefined-strings (nreverse compl)))))