unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bibtex new entry key prompt
@ 2024-11-08 13:17 Gautier Ponsinet
  2024-11-08 14:40 ` Roland Winkler
  0 siblings, 1 reply; 5+ messages in thread
From: Gautier Ponsinet @ 2024-11-08 13:17 UTC (permalink / raw)
  To: emacs-devel; +Cc: winkler

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Hello everyone,

(CC: Roland Winkler, current maintainer of bibtex.el)

The bibtex major mode to edit and maintain bibtex files has the
capability to generate key for new bibtex entry. It is very convenient.
However, when inserting a template for a new entry via `bibtex-entry',
the function always asks the user for a key. I would like to be able to
bypass this prompt since I rely on the autokey system to generate a key
after validating the entry via `bibtex-clean-entry'.

I have attached a patch to this mail, and I would like your opinion on
this.

All the best,
Gautier.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-the-user-option-bibtex-entry-ask-for-key.patch --]
[-- Type: text/x-patch, Size: 1485 bytes --]

From d62df5a257c6a9c02936e88ecb5f6fd95613ebe3 Mon Sep 17 00:00:00 2001
From: Gautier Ponsinet <gautier@gautierponsinet.xyz>
Date: Fri, 8 Nov 2024 15:07:15 +0200
Subject: [PATCH] Add the user option bibtex-entry-ask-for-key

* lisp/textmodes/bibtex.el (bibtex-entry-ask-for-key): add the user option.
(bibtex-entry): Ask the user for a key if the variable
bibtex-entry-ask-for-key is non-nil.
---
 lisp/textmodes/bibtex.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index cbcea8af012..d26b67dca7b 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1377,6 +1377,11 @@ ;;; Code:
   :version "28.1"
   :type 'function)
 
+(defcustom bibtex-entry-ask-for-key nil
+  "If non-nil, `bibtex-entry' asks for a key."
+  :group 'bibtex
+  :type 'boolean)
+
 (defcustom bibtex-entry-offset 0
   "Offset for BibTeX entries.
 Added to the value of all other variables which determine columns."
@@ -3852,7 +3857,7 @@ ;;;###autoload
    (let ((completion-ignore-case t))
      (list (completing-read "Entry Type: " bibtex-entry-alist
                             nil t nil 'bibtex-entry-type-history))))
-  (let ((key (if bibtex-maintain-sorted-entries
+  (let ((key (if bibtex-entry-ask-for-key
                  (bibtex-read-key (format "%s key: " entry-type))))
         (field-list (bibtex-field-list entry-type)))
     (unless (bibtex-prepare-new-entry (list key nil entry-type))
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-15  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 13:17 Bibtex new entry key prompt Gautier Ponsinet
2024-11-08 14:40 ` Roland Winkler
2024-11-08 15:04   ` Gautier Ponsinet
2024-11-15  5:42     ` Roland Winkler
2024-11-15  9:56       ` Gautier Ponsinet

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).