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; 4+ 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] 4+ messages in thread

* Re: Bibtex new entry key prompt
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Winkler @ 2024-11-08 14:40 UTC (permalink / raw)
  To: Gautier Ponsinet; +Cc: emacs-devel

On Fri, Nov 08 2024, Gautier Ponsinet wrote:
> 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 am wondering: is the prompt a big deal if you can just leave it blank
(that is, hit RET when the command asks for a key)?  I expect that's why
nobody worried about this for the many years this command behaves the
way it does.  Of course, providing a user option to bypass the prompt
altogether is easy to add, too.  (That's what the autokey approach is
for, but it can only do its job after all fields have been filled in.)



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

* Re: Bibtex new entry key prompt
  2024-11-08 14:40 ` Roland Winkler
@ 2024-11-08 15:04   ` Gautier Ponsinet
  2024-11-15  5:42     ` Roland Winkler
  0 siblings, 1 reply; 4+ messages in thread
From: Gautier Ponsinet @ 2024-11-08 15:04 UTC (permalink / raw)
  To: Roland Winkler; +Cc: emacs-devel

Hello,

Roland Winkler <winkler@gnu.org> [2024-11-08 08:40 -0600]:
> I am wondering: is the prompt a big deal if you can just leave it blank
> (that is, hit RET when the command asks for a key)?  I expect that's why
> nobody worried about this for the many years this command behaves the
> way it does.  Of course, providing a user option to bypass the prompt
> altogether is easy to add, too.  (That's what the autokey approach is
> for, but it can only do its job after all fields have been filled in.)

It is indeed not a big deal. I still prefer to bypass the prompt, and so
I made the change in my config by rewriting/advising the function. This
is the content of the patch attached to my previous email. And I was
simply wondering if other users would be interested.

Still, to support the change, in case the user configures the autokey
system (which I would expect many people do), the prompt for a key is
completely useless.

(Moreover, I don't use the default emacs completion system but the
vertico package, which by default select the first candidate if I hit
ENTER. I then need to enter M-ENTER to bypass the key prompt. I prefer
to insert a template and to start filling the fields immediatly.)

All the best,
Gautier.



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

* Re: Bibtex new entry key prompt
  2024-11-08 15:04   ` Gautier Ponsinet
@ 2024-11-15  5:42     ` Roland Winkler
  0 siblings, 0 replies; 4+ messages in thread
From: Roland Winkler @ 2024-11-15  5:42 UTC (permalink / raw)
  To: Gautier Ponsinet; +Cc: emacs-devel

I installed a slightly modified version of your patch,
commit cc9188b1900.

Roland



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

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

Thread overview: 4+ 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

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).