From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Roland Winkler Newsgroups: gmane.emacs.devel Subject: Re: master 45a1653: ; Fix last change to bibtex.el Date: Sat, 28 Nov 2020 16:32:00 -0600 Message-ID: <87czzx3yfz.fsf@gnu.org> References: <20201116233108.21940.22514@vcs0.savannah.gnu.org> <20201116233110.4E83E209DE@vcs0.savannah.gnu.org> <87k0ujthyb.fsf@gnu.org> <875z6226fg.fsf@tcd.ie> <11259.90054.698979.24501@gargle.gargle.HOWL> <877dqizkpn.fsf@tcd.ie> <21967.72026.373783.24501@gargle.gargle.HOWL> <39049.45143.465640.24501@gargle.gargle.HOWL> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27856"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: "Basil L. Contovounesios" , Glenn Morris , Francesco Potort=AC , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 28 23:32:46 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kj8lq-0007Aa-88 for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Nov 2020 23:32:46 +0100 Original-Received: from localhost ([::1]:42254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kj8lp-0003Ns-AX for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Nov 2020 17:32:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kj8lC-0002tQ-3V for emacs-devel@gnu.org; Sat, 28 Nov 2020 17:32:06 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:51638) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kj8lA-00049n-Ci; Sat, 28 Nov 2020 17:32:04 -0500 Original-Received: from [2602:30a:2e52:d720:65b7:1416:12e7:8bfb] (port=42228 helo=regnitz) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1kj8l8-0006to-BI; Sat, 28 Nov 2020 17:32:02 -0500 In-Reply-To: <39049.45143.465640.24501@gargle.gargle.HOWL> (Roland Winkler's message of "Wed, 18 Nov 2020 15:56:25 -0600") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259980 Archived-At: On Wed, Nov 18 2020, Roland Winkler wrote: > On Wed Nov 18 2020 Stefan Monnier wrote: >> And indeed with the :safe keyword you can specify a number of >> value that can be assumed to be safe, while any other value will >> be raise alarms. > > Thanks, I am always happy to learn new things. I'll try it out and > send a patch. Unless anyone complains I'll apply the following patch. diff --git a/etc/NEWS b/etc/NEWS index 2fb33e3..7b4c767 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1349,7 +1349,7 @@ completions with more information in completion prefix and suffix. *** User option 'completions-format' supports a new value 'one-column'. --- -*** New user option 'bibtex-unify-case-convert'. +*** New user option 'bibtex-unify-case-function'. This new option allows the user to customize how case is converted when unifying entries. diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index c9e21e5..001941f 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -88,16 +88,6 @@ bibtex-include-OPTkey (const :tag "Default" t)) :risky t) -(defcustom bibtex-unify-case-convert #'identity - "Function called when unifying case on entry and field names. -It is called with one argument, the entry or field name." - :version "28.1" - :type '(choice (const :tag "Same case as in `bibtex-field-alist'" identity) - (const :tag "Downcase" downcase) - (const :tag "Capitalize" capitalize) - (const :tag "Upcase" upcase) - (function :tag "Conversion function"))) - (defcustom bibtex-user-optional-fields '(("annote" "Personal annotation (ignored)")) "List of optional fields the user wants to have always present. @@ -133,7 +123,7 @@ bibtex-entry-format delimiters Change delimiters according to variables `bibtex-field-delimiters' and `bibtex-entry-delimiters'. unify-case Change case of entry and field names according to - `bibtex-unify-case-convert'. + `bibtex-unify-case-function'. braces Enclose parts of field entries by braces according to `bibtex-field-braces-alist'. strings Replace parts of field entries by string constants @@ -193,6 +183,17 @@ bibtex-field-strings-alist (regexp :tag "From regexp") (regexp :tag "To string constant")))) +(defcustom bibtex-unify-case-function #'identity + "Function for unifying case of entry and field names. +It is called with one argument, the entry or field name." + :version "28.1" + :type '(choice (const :tag "Same case as in `bibtex-field-alist'" identity) + (const :tag "Downcase" downcase) + (const :tag "Capitalize" capitalize) + (const :tag "Upcase" upcase) + (function :tag "Conversion function")) + :safe (lambda (x) (memq x '(upcase downcase capitalize identity)))) + (defcustom bibtex-clean-entry-hook nil "List of functions to call when entry has been cleaned. Functions are called with point inside the cleaned entry, and the buffer @@ -2357,7 +2358,7 @@ bibtex-format-entry ;; unify case of entry type (when (memq 'unify-case format) (delete-region beg-type end-type) - (insert (funcall bibtex-unify-case-convert (car entry-list)))) + (insert (funcall bibtex-unify-case-function (car entry-list)))) ;; update left entry delimiter (when (memq 'delimiters format) @@ -2566,7 +2567,7 @@ bibtex-format-entry (curname (buffer-substring beg-name end-name))) (delete-region beg-name end-name) (goto-char beg-name) - (insert (funcall bibtex-unify-case-convert + (insert (funcall bibtex-unify-case-function (or fname curname))))) ;; update point