As far as I searched, both in the web and in Emacs internal documentation, I couldn't find an up to date manual for BibTeX mode (If anyone knows where to find it, please let me know). There are the docstrings in
bibtex.el of course, which already go a long way. But there is an old version of a manual made available online by a good soul.
There, we find the following comment regarding
If you want to change this variable, the best idea might be to get the source code of BibTeX mode from file 'bibtex.el', copy this variable's definition to your '.emacs' file, change it to a setq statement (see section 'Setting Variables' in Emacs Lisp Manual), and modify the variable's contents.
That's quite certainly the proper/canonical way do deal with this. It does work indeed. You can also customize
bibtex-biblatex-entry-alist to equivalent effect.
The only "problem" with that, is that
bibtex-biblatex-entry-alist is about 250 lines of code and
bibtex-biblatex-field-alist another almost 90. Plus the ones I want to add. That's quite a lot, in my view.
What goes wrong with my initial approach as set in the question is that the menus and commands get built upon loading
bibtex.el, thus using the original value of the lists as defined there, and my
appends come too late, when menu/commands are already built.
An alternative to redefining the full lists would be to rebuild the menu/commands after I've appended to the lists. Unfortunately,
bibtex.el does not wrap this routine in any sort of function we could then call, so we'd have to bring the corresponding code.
(bibtex-dialect (quote biblatex));; biblatex as default bib format
;; Support for custom biblatex entries and fields in BibTeX mode
;; Taken from bibtex.el, the routine that builds the menus etc.
;; This must be (re)executed after `bibtex-biblatex-entry-alist` and
;; `bibtex-biblatex-field-alist` have been redefined. Alternative is to
;; redefine the *full* lists with `setq` in the `:init` section
(let ((select-map (make-sparse-keymap)))
;; Submenu for selecting the dialect
(dolist (dialect (reverse bibtex-dialect-list))
(define-key select-map (vector dialect)
`(menu-item ,(symbol-name dialect)
(lambda () (interactive) (bibtex-set-dialect ',dialect t))
:button (:radio . (eq bibtex-dialect ',dialect)))))
;; We define a menu for each dialect.
;; Then we select the menu we want via the :visible keyword
(dolist (dialect bibtex-dialect-list)
(let ((entry-alist (bibtex-entry-alist dialect))
(define-key menu-map [select]
`(menu-item "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 entry-alist))
;; Entry commands
(let* ((entry (car elt))
(fname (intern (format "bibtex-%s" entry))))
(unless (fboundp fname)
(eval (list 'defun fname nil
(format "Insert a template for a @%s entry; see also `bibtex-entry'."
;; Menu entries
(define-key menu-map (vector fname)
`(menu-item ,(or (nth 1 elt) (car elt)) ,fname))))
(vector 'menu-bar dialect)
`(menu-item "Entry-Types" ,menu-map
:visible (eq bibtex-dialect ',dialect))))))
;; End of taken from bibtex.el
That's shorter, I'm not sure it is wiser though. Still, it does work.
Update: For the record. I eventually chose to customize the full lists. It feels wiser, despite the code overhead.