Function: bibtex-init-dialect

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

Signature

(bibtex-init-dialect DIALECT)

Documentation

Initialize BibTeX DIALECT.

Define commands to insert templates for the entry types of DIALECT. Also define a menu map for these commands.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
;; We define a menu map for each dialect.
;; Then we select the menu map we want via the :visible keyword

(defun bibtex-init-dialect (dialect)
  "Initialize BibTeX DIALECT.
Define commands to insert templates for the entry types of DIALECT.
Also define a menu map for these commands."
  (let ((menu-map (make-sparse-keymap))
        (aux (length (symbol-value
                      (intern (format "bibtex-%s-aux-entry-alist" dialect)))))
        (cnt 0))
    (define-key menu-map [select]
                `(menu-item "BibTeX dialect" ,bibtex-dialect-select-map))
    (define-key menu-map [nil-2] '(menu-item "--"))
    (define-key menu-map [bibtex-preamble]
                '(menu-item "Preamble" bibtex-Preamble))
    (define-key menu-map [bibtex-String]
                '(menu-item "String" bibtex-String))
    (define-key menu-map [nil-1] '(menu-item "--"))
    (dolist (elt (reverse (bibtex-entry-alist dialect)))
      ;; Entry commands
      (let* ((entry (car elt))
             (fname (intern (format "bibtex-%s" entry))))
        (unless (fboundp fname)
          (defalias fname
            (lambda ()
              (:documentation
               (format "Insert a template for a @%s entry; see also `bibtex-entry'."
                       entry))
              (interactive "*")
              (bibtex-entry entry))))
        ;; Menu entries
        (define-key menu-map (vector fname)
                    `(menu-item ,(or (nth 1 elt) (car elt)) ,fname))
        ;; Put separator between regular entries in `bibtex-DIALECT-entry-alist'
        ;; and auxiliary entries in `bibtex-DIALECT-aux-entry-alist'.
        (setq cnt (1+ cnt))
        (if (= aux cnt)
            (define-key menu-map [nil-3] '(menu-item "--")))))

    ;; If we already have a menu map for DIALECT, replace it with the new one.
    (let ((km (assq 'menu-bar (cdr bibtex-mode-map))))
      (if (and km (setq km (assq dialect (nthcdr 2 km))))
          (setcdr (nthcdr 2 km) (list menu-map
                                      :visible `(eq bibtex-dialect ',dialect)))
        (define-key bibtex-mode-map
                    (vector 'menu-bar dialect)
                    `(menu-item "Entry-Types" ,menu-map
                                :visible (eq bibtex-dialect ',dialect)))))))